Sharedsupport / 2015-03-11-102341 prime power.sagewsOpen in CoCalc
Authors: Harald Schilly, ℏal Snyder, William A. Stein
License: GNU General Public License v3.0
Description: Examples for support purposes.
is_prime_power(4)
True
is_prime_power(2)
True
[n for n in [1..100] if is_prime_power(n)]
[1, 2, 3, 4, 5, 7, 8, 9, 11, 13, 16, 17, 19, 23, 25, 27, 29, 31, 32, 37, 41, 43, 47, 49, 53, 59, 61, 64, 67, 71, 73, 79, 81, 83, 89, 97]
is_prime_power?
File: /usr/local/sage/sage-6.5/local/lib/python2.7/site-packages/sage/rings/arith.py Signature : is_prime_power(n, flag=0) Docstring : Returns True if n is a prime power, and False otherwise. The result is proven correct - *this is NOT a pseudo-primality test!*. INPUT: * "n" - an integer or rational number * "flag (for primality testing)" - int * "0" (default): use a combination of algorithms. * "1": certify primality using the Pocklington-Lehmer Test. * "2": certify primality using the APRCL test. EXAMPLES: sage: is_prime_power(389) True sage: is_prime_power(2000) False sage: is_prime_power(2) True sage: is_prime_power(1024) True sage: is_prime_power(-1) False sage: is_prime_power(1) True sage: is_prime_power(997^100) True sage: is_prime_power(1/2197) True sage: is_prime_power(1/100) False sage: is_prime_power(2/5) False