Skip to main content

P–1Dem

Pollard p − 1 Demonstration

Compute gcd⁡(ak!−1,n)\gcd(a^{k!}-1,n) one value of kk at a time

Pollard p − 1 method

At step kk, the current residue is bk≡ak!(modn)b_k\equiv a^{k!}\pmod n. If a prime p∣np\mid n has p−1∣k!p-1\mid k!, Fermat’s theorem gives p∣bk−1p\mid b_k-1.
  1. 1Begin with b0=ab_0=a.
  2. 2Compute bk≡bk−1k(modn)b_k\equiv b_{k-1}^{k}\pmod n, so bk≡ak!(modn)b_k\equiv a^{k!}\pmod n.
  3. 3Evaluate gk=gcd⁡(bk−1,n)g_k=\gcd(b_k-1,n).
  4. 4Stop when gk>1g_k>1; it is useful when 1<gk<n1<g_k<n.