Talk:Giuga numbers

From Rosetta Code
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Is there a simpler way for generating the squarefree numbers

Giuga numbers are squarefree and therefor are simple product of different primes n = p1*p2..*pk.|p1<p2<..<pk
How big can the last prime factor pk get:
(n div pk -1) mod pk = z=[1,2,3...] | *pk
n div pk -1 = z*pk
(p1*p2*..*p(k-1))-1 = z*pk => pk must be a multible of (product of all other prime factors -1)
Examples:
2*3-1 = 5 ->pk= 5 -> n =2*3*5=30, no need to search on three factors starting with 2,3
2*3*7-1 = 41->pk= 41 -> n =2*3*7*41=1722
2*3*11-1 = 65 == z*pk AND pk>11 AND pk is divisor of 65 => pk =13 ->2*3*11*13 =858

2*3*11*17-1 = 1121 = z*pk == 19*59 -> pk =19 and 59 are possible to check 21318 and 66198

My intention is to extend the first k-1 prime factors and check for pk and then for guiga.
--Horsth (talk) 12:33, 2 July 2022 (UTC)