OFFSET
6,2
COMMENTS
It is conjectured that an integer is always reached if the initial value n/3 is >= 2.
LINKS
Benoit Cloitre, Graph of (sum(k=6,n,a(k))-2n)*n^(-1/2), pdf
FORMULA
a(n)=0 iff n == 0 (mod 3), a(n)==1 iff n == 1 or 2 (mod 3^2), a(n)=2 iff n == 14,22,25,26 (mod 3^3). In general a(n)=m iff n == x (mod 3^m) where x pertains to a set of 2^m distinct elements included in {1,2,...,(3^m)-1}. Conjecture: a(6) + a(7) + a(8) + ... + a(n) = 2n + O(sqrt(n)). - Benoit Cloitre, Sep 24 2012
MAPLE
# Gives right answer as long as answer is < M.
# This is better than the Mathematica or PARI programs.
M := 50; f := proc(n) local c, k, tn, tf; global M; k := n/3; c := 0; while whattype(k) <> 'integer' do tn := floor(k); tf := k-tn; tn := tn mod 3^50; k := tn*(tn+tf); c := c+1; od: c; end; # N. J. A. Sloane
MATHEMATICA
f[n_] := If[ Mod[3n, 3] == 0, 0, Length[ NestWhileList[ #1*Floor[ #1] &, n, !IntegerQ[ #2] &, 2]] - 1]; Table[f[n/3], {n, 6, 120}] (* Robert G. Wilson v *)
PROG
(PARI) a(n)=if(n<0, 0, c=n/3; x=0; while(frac(c)>0, c=c*floor(c); x++); x) \\ Benoit Cloitre, Sep 29 2003
(Python)
def A087666(n):
c, x = 0, n
a, b = divmod(x, 3)
while b != 0:
x *= a
c += 1
a, b = divmod(x, 3)
return c # Chai Wah Wu, Mar 01 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Sep 27 2003
EXTENSIONS
More terms from Benoit Cloitre, Sep 29 2003
STATUS
approved