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 bkak!(modn)b_k\equiv a^{k!}\pmod n. If a prime pnp\mid n has p1k!p-1\mid k!, Fermat’s theorem gives pbk1p\mid b_k-1.
  1. 1Begin with b0=ab_0=a.
  2. 2Compute bkbk1k(modn)b_k\equiv b_{k-1}^{k}\pmod n, so bkak!(modn)b_k\equiv a^{k!}\pmod n.
  3. 3Evaluate gk=gcd(bk1,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.