A072491 Define f(1) = 0. For n>=2, let f(n) = n - p where p is the largest prime <= n. a(n) = number of iterations of f to reach 0, starting from n.
0, 1, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 3, 2, 1, 2, 1, 2, 2, 2, 3, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 3, 2, 1, 2, 2, 2, 3, 2, 1, 2, 1, 2, 2, 2, 3, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 2, 3, 2, 1, 2, 2, 2, 1, 2, 2, 2, 3, 2, 1, 2, 2, 2, 3, 2, 3, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2
Offset: 0
Examples
a(27)=3 as f(27)=27-23=4, f(4)=4-3=1 and f(1)=0.
References
- S. S. Pillai, "An arithmetical function concerning primes", Annamalai University Journal (1930), pp. 159-167.
Links
- Antti Karttunen, Table of n, a(n) for n = 0..10007
Crossrefs
Programs
-
Mathematica
f[1]=0; f[n_] := n-Prime[PrimePi[n]]; a[n_] := Module[{k, x}, For[k=0; x=n, x>0, k++; x=f[x], Null]; k]
-
PARI
a(n)=if(n<4,n>0,1+a(n-precprime(n))) \\ Charles R Greathouse IV, Feb 04 2013
Formula
On Cramér's conjecture, a(n) = O(log* n). - Charles R Greathouse IV, Feb 04 2013
Extensions
Edited by Dean Hickerson, Nov 26 2002
a(0) = 0 prepended by Antti Karttunen, Aug 09 2015
Comments