Jacques Gélinas on Mon, 01 Oct 2018 18:08:16 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Learning with GP: Factorization of F6=2^64+1 - Fermat


Fermat noted in 1640 that 2^1+1, 2^2+1, 2^4+1, 2^8+1, 2^16+1 were prime numbers.

------------------------------ Start cut
F(n)  = 2^2^n + 1;                       \\definition of Fn
Fs(n) = 1<<(1<<n) + 1;                   \\left shifts
Fr(n) = if(n<1,3*(n==0),(Fr(n-1)-1)^2+1);\\recursion http://oeis.org/A000215
Fd(n) = my(m=2^n+1); fromdigits(vector(m,i,i==1||i==m),2); \\Bill Alombert
Fv(N) = my(m=2); vector(N,n,(m*=m)+1);   \\iteration skips F0=3

#F(12) == 65                             \\1+2^n\64 words used for Fn
apply(n->#digits(n),Fv(12)) ==           \\decimal digits in Fn
     [1, 2, 3, 5, 10, 20, 39, 78, 155, 309, 617, 1234]
Fv(12)%10 == [5,7,7,7,7,7,7,7,7,7,7,7]   \\last digit is 7 [2]

\\ a^(p-1)=1(mod p),p prime,(a,p)=1 (Knuth, The Art of Comp. Prog. II.4.5.4)
Fermat(n) = my(a=3,p=F(n)); for(k=1,2^n,a=sqr(a)%p); a%p==1;
apply(Fermat,[1..12]) == [1,1,1,1,0,0,0,0,0,0,0,0]
isprime(Fv(12)) == [1,1,1,1,0,0,0,0,0,0,0,0] \\no primes known for n>4

SPF = apply( n->factor(n)[1,1], Fv(8));  \\smallest prime factor
SPF == [5, 17, 257, 65537, 641, 274177, 59649589127497217, 1238926361552897]
SPF%10 == [5, 7, 7, 7, 1, 7, 7, 7]       \\one factor ends in 7 ???

\\is p a prime factor ? Charles R Greathouse IV, 2013, http://oeis.org/A023394
ispf(p) = p>2 && Mod(2, p)^lift(Mod(2, znorder(Mod(2, p)))^p)==1 && isprime(p);
apply(ispf,SPF) == [1, 1, 1, 1, 1, 1, 1, 1]

------------------------------ End paste

?? Could someone explain the ispf() one-liner program, 
   assuming that one understands the tutorial [3, p. 12] ??


------------------------------ Features used [4]
Operators: +, *, <, =, >, *=, ==, #, %, ->, ||, <<, "[,]"(select), ^(right associative)
Constructors: [a..b], [a,b,...], vector, Mod
Functions: sqr, isprime, factor, apply, fromdigits, lift, znorder, (recursivity)

------------------------------ Links
[1] Dickson, 1952, Chapter XV: http://archive.org/details/HistoryOfTheTheoryOfNumbersI
[2] Proofs by Ph.B.: http://tomlr.free.fr/Math%E9matiques/Fichiers%20Claude/Les%20Nombres%20De%20Fermat(Fermat,%20Maths,%20Math%E9matiques,%20Nombre%20Particulier).pdf
[3] Tutorial: http://pari.math.u-bordeaux.fr/pub/pari/manuals/2.11.0/tutorial.pdf
[4] Reference card: http://pari.math.u-bordeaux.fr/pub/pari/manuals/2.11.0/refcard.pdf


Jacques Gélinas                  Next: Factorization of F6=2^64+1 - Euler, Lucas