A285700 a(n) = Number of iterations x -> 2x-1 needed to get a nonprime number, when starting with x = n.
0, 3, 2, 0, 1, 0, 2, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0
Offset: 1
Keywords
Links
- Antti Karttunen, Table of n, a(n) for n = 1..10000
Programs
-
Mathematica
Array[Length@ NestWhileList[2 # - 1 &, #, PrimeQ@ # &] - 1 &, 120] (* Michael De Vlieger, Apr 26 2017 *)
-
Python
from sympy import isprime def a(n): return 0 if isprime(n) == 0 else 1 + a(2*n - 1) # Indranil Ghosh, Apr 26 2017
-
Scheme
(define (A285700 n) (if (zero? (A010051 n)) 0 (+ 1 (A285700 (+ n n -1)))))