login
A285700
a(n) = Number of iterations x -> 2x-1 needed to get a nonprime number, when starting with x = n.
3
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,2
LINKS
FORMULA
If A010051(n) = 0 [when n is a nonprime], a(n) = 0, otherwise a(n) = 1 + a((2*n)-1).
a(A000040(n)) = A181715(n).
MATHEMATICA
Array[Length@ NestWhileList[2 # - 1 &, #, PrimeQ@ # &] - 1 &, 120] (* Michael De Vlieger, Apr 26 2017 *)
PROG
(Scheme) (define (A285700 n) (if (zero? (A010051 n)) 0 (+ 1 (A285700 (+ n n -1)))))
(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
CROSSREFS
Cf. A000040, A005382 (positions of terms > 1), A010051, A181715, A285701.
Sequence in context: A144553 A187130 A187145 * A290693 A131290 A138741
KEYWORD
nonn
AUTHOR
Antti Karttunen, Apr 26 2017
STATUS
approved