OFFSET
0,1
COMMENTS
The 'Px+1 map': if x is divisible by any prime < P then divide out these primes one at a time starting with the smallest; otherwise multiply x by P and add 1.
LINKS
MAPLE
with(numtheory): a := proc(n, S, Q) option remember: local k; if n=0 then RETURN(S); fi: for k from 1 to Q do if a(n-1, S, Q) mod ithprime(k) = 0 then RETURN(a(n-1, S, Q)/ithprime(k)); fi: od: RETURN(ithprime(Q+1)*a(n-1, S, Q)+1) end; # run with S=13 and Q=5.
MATHEMATICA
a[n_, S_, Q_] := a[n, S, Q] = Module[{k}, If[n == 0, S, For[k = 1, k <= Q, k++, If[Mod[a[n-1, S, Q], Prime[k]] == 0, Return[a[n-1, S, Q]/Prime[k]]] ]; Prime[Q+1]*a[n-1, S, Q] + 1]];
Table[a[n, 13, 5], {n, 0, 60}] (* Jean-François Alcover, Jul 13 2016, adapted from Maple *)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
N. J. A. Sloane, Oct 20 2000
STATUS
approved