login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

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