A059981 Order of compositeness for the n-th composite number.
1, 1, 1, 2, 1, 2, 1, 2, 3, 2, 1, 3, 1, 2, 3, 4, 1, 3, 1, 2, 4, 2, 1, 3, 4, 5, 2, 4, 1, 2, 1, 3, 5, 3, 2, 4, 1, 5, 6, 3, 1, 5, 1, 2, 3, 2, 1, 4, 6, 4, 3, 5, 1, 2, 6, 7, 4, 2, 1, 6, 1, 2, 3, 4, 3, 2, 1, 5, 7, 5, 1, 4, 1, 6, 2, 3, 7, 8, 1, 5, 3, 2, 1, 7, 2, 3, 4
Offset: 1
Examples
16 is 9th composite number, so S(16)=9, 9 is 4th composite, so S(S(16))=4, 4 is first composite number, so S(S(S(16)))=1, not a composite number. Thus a(9)=3. 4 is the first composite number, so S(4)=1, not a composite number. Thus a(1)=1.
Links
- T. D. Noe, Table of n, a(n) for n = 1..1000
Programs
-
Mathematica
Composite[ n_Integer ] := (k = n + PrimePi[ n ] + 1; While[ k != n + PrimePi[ k ] + 1, k++ ]; k); CompositePi[ n_Integer ] := (n - 1 - PrimePi[ n ]); Attributes[ Composite ] = Attributes[ CompositePi ] = Listable; Table[ c = 1; k = CompositePi[ Composite[ n ] ]; While[ ! (PrimeQ[ k ] || k == 1), k = CompositePi[ k ]; c++ ]; c, {n, 100} ]
Comments