login
a(n) = Number of iterations x -> 2x-1 needed to get a nonprime number, when starting with x = n.
3

%I #11 Apr 26 2017 21:48:03

%S 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,

%T 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,

%U 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

%N a(n) = Number of iterations x -> 2x-1 needed to get a nonprime number, when starting with x = n.

%H Antti Karttunen, <a href="/A285700/b285700.txt">Table of n, a(n) for n = 1..10000</a>

%F If A010051(n) = 0 [when n is a nonprime], a(n) = 0, otherwise a(n) = 1 + a((2*n)-1).

%F a(A000040(n)) = A181715(n).

%t Array[Length@ NestWhileList[2 # - 1 &, #, PrimeQ@ # &] - 1 &, 120] (* _Michael De Vlieger_, Apr 26 2017 *)

%o (Scheme) (define (A285700 n) (if (zero? (A010051 n)) 0 (+ 1 (A285700 (+ n n -1)))))

%o (Python)

%o from sympy import isprime

%o def a(n): return 0 if isprime(n) == 0 else 1 + a(2*n - 1) # _Indranil Ghosh_, Apr 26 2017

%Y Cf. A000040, A005382 (positions of terms > 1), A010051, A181715, A285701.

%K nonn

%O 1,2

%A _Antti Karttunen_, Apr 26 2017