Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 1020

Chapter 15 - Arithmetic Functions

Perfect Numbers

The following procedure will search for perfect numbers less than 106:

for n in range(1,10^6): if sigma(n)==2*n: print(n)
6 28 496 8128

Mersenne primes and perfect numbers

%md The following procedure searches for Mersenne primes among the first 20 prime exponents. The output includes the exponent, the Mersenne prime, and the corresponding perfect number.

The following procedure searchs for Mersenne primes among the first 20 prime exponents. The output includes the exponent, the Mersenne prime, and the corresponding perfect number.

P=Primes() for n in range(0,19): p=P.unrank(n) if is_prime(2^p-1): print(p,2^p-1,2^(p-1)*(2^p-1))
(2, 3, 6) (3, 7, 28) (5, 31, 496) (7, 127, 8128) (13, 8191, 33550336) (17, 131071, 8589869056) (19, 524287, 137438691328) (31, 2147483647, 2305843008139952128) (61, 2305843009213693951, 2658455991569831744654692615953842176)

Product Expansion for Proposition 15.51

f=expand(prod(1-x^k for k in range(1,51))) table([(j,(f.coefficient(x,j))) for j in [1..51]], header_row=["n", "Coeff. of x^n"], frame=True)
+----+---------------+ | n | Coeff. of x^n | +====+===============+ | 1 | -1 | +----+---------------+ | 2 | -1 | +----+---------------+ | 3 | 0 | +----+---------------+ | 4 | 0 | +----+---------------+ | 5 | 1 | +----+---------------+ | 6 | 0 | +----+---------------+ | 7 | 1 | +----+---------------+ | 8 | 0 | +----+---------------+ | 9 | 0 | +----+---------------+ | 10 | 0 | +----+---------------+ | 11 | 0 | +----+---------------+ | 12 | -1 | +----+---------------+ | 13 | 0 | +----+---------------+ | 14 | 0 | +----+---------------+ | 15 | -1 | +----+---------------+ | 16 | 0 | +----+---------------+ | 17 | 0 | +----+---------------+ | 18 | 0 | +----+---------------+ | 19 | 0 | +----+---------------+ | 20 | 0 | +----+---------------+ | 21 | 0 | +----+---------------+ | 22 | 1 | +----+---------------+ | 23 | 0 | +----+---------------+ | 24 | 0 | +----+---------------+ | 25 | 0 | +----+---------------+ | 26 | 1 | +----+---------------+ | 27 | 0 | +----+---------------+ | 28 | 0 | +----+---------------+ | 29 | 0 | +----+---------------+ | 30 | 0 | +----+---------------+ | 31 | 0 | +----+---------------+ | 32 | 0 | +----+---------------+ | 33 | 0 | +----+---------------+ | 34 | 0 | +----+---------------+ | 35 | -1 | +----+---------------+ | 36 | 0 | +----+---------------+ | 37 | 0 | +----+---------------+ | 38 | 0 | +----+---------------+ | 39 | 0 | +----+---------------+ | 40 | -1 | +----+---------------+ | 41 | 0 | +----+---------------+ | 42 | 0 | +----+---------------+ | 43 | 0 | +----+---------------+ | 44 | 0 | +----+---------------+ | 45 | 0 | +----+---------------+ | 46 | 0 | +----+---------------+ | 47 | 0 | +----+---------------+ | 48 | 0 | +----+---------------+ | 49 | 0 | +----+---------------+ | 50 | 0 | +----+---------------+ | 51 | 2 | +----+---------------+
︠5e4525e3-b0c9-4ea2-867d-04159e7a25cd︠