The following standalone Sage script factors integers, polynomials, etc:
#!/usr/bin/env sage -python import sys from sage.all import * if len(sys.argv) != 2: print "Usage: %s <n>"%sys.argv[0] print "Outputs the prime factorization of n." sys.exit(1) print factor(sage_eval(sys.argv[1]))
SAGE_ROOT
must
be in your PATH. If the above script is called factor
,
here is an example usage:
bash $ ./factor 2006 2 * 17 * 59 bash $ ./factor "32*x^5-1" (2*x - 1) * (16*x^4 + 8*x^3 + 4*x^2 + 2*x + 1)
See About this document... for information on suggesting changes.