

A246370


a(1)=0, a(p_n) = 1 + a(n), a(c_n) = a(n), where p_n = nth prime = A000040(n), c_n = nth composite number = A002808(n); Also number of nonleading 0bits in the binary representation of A135141(n).


6



0, 1, 2, 0, 3, 1, 1, 2, 0, 3, 4, 1, 2, 1, 2, 0, 2, 3, 3, 4, 1, 2, 1, 1, 2, 0, 2, 3, 4, 3, 5, 4, 1, 2, 1, 1, 2, 2, 0, 2, 3, 3, 2, 4, 3, 5, 3, 4, 1, 2, 1, 1, 1, 2, 2, 0, 2, 3, 3, 3, 4, 2, 4, 3, 5, 3, 4, 4, 1, 2, 5, 1, 2, 1, 1, 2, 2, 0, 3, 2, 3, 3, 2, 3, 4, 2, 4, 3, 2, 5, 3, 4, 4, 1, 2, 5, 3, 1, 2, 1, 1, 1, 3, 2, 2, 0, 4, 3, 5, 2, 3, 3, 4, 2, 3, 4, 2, 4, 3, 2
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,3


LINKS

Antti Karttunen, Table of n, a(n) for n = 1..32998


FORMULA

a(1) = 1, and for n >= 1, if A010051(n) = 1 [i.e. when n is prime], a(n) = 1 + a(A000720(n)), otherwise a(n) = a(A065855(n)). [A000720(n) and A065855(n) tell the number of primes, and respectively, composites <= n].
a(n) = A080791(A135141(n)). [a(n) tells also the number of nonleading zeros in binary representation of A135141(n)].
a(n) = A000120(A246377(n))1. [Respectively, one less than the number of 1bits in 0/1swapped version of that sequence].
a(n) = A246348(n)  A246369(n)  1.


EXAMPLE

Consider n=30. It is the 19th composite number in A002808: 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, ...
Thus we consider next n=19, which is the 8th prime in A000040: 2, 3, 5, 7, 11, 13, 17, 19, ...
So we proceed with n=8, which is the 3rd composite number, and then with n=3, which is the 2nd prime, and then with n=2 which is the 1st prime, and we have finished.
All in all, it took us 5 steps (A246348(30) = 6 = 5+1) to reach 1, and on the journey, we encountered three primes, 19, 3 and 2, thus a(30) = 3.


PROG

(Scheme, two versions, the first being a direct recurrence employing memoizing definecmacro from Antti Karttunen's IntSeqlibrary):
(definec (A246370 n) (cond ((= 1 n) 0) ((= 1 (A010051 n)) (+ 1 (A246370 (A000720 n)))) (else (A246370 (A065855 n)))))
(define (A246370 n) (A080791 (A135141 n)))


CROSSREFS

Cf. A000040, A002808, A000720, A065855, A080791, A135141, A246348, A246369, A246377.
Sequence in context: A113504 A276165 A124754 * A047983 A070812 A308230
Adjacent sequences: A246367 A246368 A246369 * A246371 A246372 A246373


KEYWORD

nonn


AUTHOR

Antti Karttunen, Aug 27 2014


STATUS

approved



