login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A121561 The number of iterations of "subtract the largest prime less than or equal to the current value" to go from n to the limiting value 0 or 1. 9

%I #14 Jul 27 2022 02:15:58

%S 0,1,1,1,1,1,1,1,2,2,1,1,1,1,2,2,1,1,1,1,2,2,1,1,2,2,2,2,1,1,1,1,2,2,

%T 2,2,1,1,2,2,1,1,1,1,2,2,1,1,2,2,2,2,1,1,2,2,2,2,1,1,1,1,2,2,2,2,1,1,

%U 2,2,1,1,1,1,2,2,2,2,1,1,2,2,1,1,2,2,2,2,1,1,2,2,2,2,2,2,1,1,2,2,1,1,1,1,2

%N The number of iterations of "subtract the largest prime less than or equal to the current value" to go from n to the limiting value 0 or 1.

%C Number of steps to go from n to A121559(n).

%C The sequence has the form of blocks of numbers; see A121562 for the lengths of those blocks.

%H Robert G. Wilson v, <a href="/A121561/b121561.txt">Table of n, a(n) for n = 1..100000</a>

%e a(9) = 2 because there are 2 steps in going from 9 to 0 in A121559: 9 mod 7 = 2 and 2 mod 2 = 0.

%t LrgstPrm[n_] := Block[{k = n}, While[ !PrimeQ@ k, k-- ]; k]; f[n_] := Block[{c = 0, d = n}, While[d > 1, d = d - LrgstPrm@d; c++ ]; c]; Array[f, 105] (* _Robert G. Wilson v_, Feb 29 2008 *)

%o (Python)

%o from sympy import prevprime

%o def a(n): return 0 if n == 0 or n == 1 else 1 + a(n - prevprime(n+1))

%o print([a(n) for n in range(1, 106)]) # _Michael S. Branicky_, Jul 26 2022

%Y Cf. A121559, A064722, a(n)=1: A093515, a(n)=2: A093513, a(n)=3: A138026, a(n)=4: A138027.

%K easy,nonn

%O 1,9

%A _Kerry Mitchell_, Aug 07 2006

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 08:13 EDT 2024. Contains 371922 sequences. (Running on oeis4.)