A225721 Starting with x = n, the number of iterations of x := 2x - 1 until x is prime, or -1 if no prime exists.
-1, 0, 0, 1, 0, 1, 0, 2, 1, 1, 0, 1, 0, 2, 1, 1, 0, 3, 0, 6, 1, 1, 0, 1, 2, 2, 1, 2, 0, 1, 0, 8, 3, 1, 2, 1, 0, 2, 5, 1, 0, 1, 0, 2, 1, 2, 0, 583, 1, 2, 1, 1, 0, 1, 1, 4, 1, 2, 0, 5, 0, 4, 7, 1, 2, 1, 0, 2, 1, 1, 0, 3, 0, 2, 1, 1, 4, 3, 0, 2, 3, 1, 0, 1, 2, 4
Offset: 1
Keywords
Examples
For a(20), the trajectory is 20->39->77->153->305->609->1217, a prime number. That required 6 steps, so a(20)=6.
Links
- Christian N. K. Anderson, Table of n, a(n) for n = 1..10000
Crossrefs
Cf. A050921 (primes obtained).
Programs
-
R
y=as.bigz(rep(0,500)); ys=rep(0,500); for(i in 1:500) { n=as.bigz(i); k=0; while(isprime(n)==0 & ndig(n)<1000 & k<5000) { k=k+1; n=2*n-1 } if(ndig(n)>=1000 | k>=5000) { ys[i]=-1; y[i]=-1; } else {ys[i]=k; y[i]=n; } }
Comments