login
Smallest number of iterations k such that A068527^(k)(n)=A068527^(k+1)(n).
1

%I #11 Nov 18 2014 03:26:29

%S 1,0,2,1,2,3,1,2,1,4,3,2,3,1,2,1,3,2,4,3,2,3,1,2,1,5,2,3,2,4,3,2,3,1,

%T 2,1,3,4,5,2,3,2,4,3,2,3,1,2,1,2,4,3,4,5,2,3,2,4,3,2,3,1,2,1,2,3,2,4,

%U 3,4,5,2,3,2,4,3,2,3,1,2,1,3,4,2,3,2,4,3,4,5,2,3,2,4,3,2,3,1,2,1

%N Smallest number of iterations k such that A068527^(k)(n)=A068527^(k+1)(n).

%C Given a number n, denote its distance from next perfect square >= n as R(n), sequence A068527. The function R(n) has two fixed points, 0 and 2, and for all n>=3, R(n)<n. Thus for any n>=0, there exists a k>=0 such that R^(k)(n)=R^(k+1)(n)=0 or 2. This sequence gives the number of iterations needed to reach the fixed point starting at n.

%C This sequence is unbounded, but grows very slowly, reaching records of 1, 2, 3, 4, 6 etc at n=1, 3, 6, 10, 26, 170, 7226, etc.

%e R(10) = 6, R(6) = 3, R(3) = 1, R(1) = 0, R(0) = 0. Thus a(10) = 4.

%p A249160 := proc(n)

%p local k,prev,this;

%p prev := n ;

%p for k from 1 do

%p this := A068527(prev) ;

%p if this = prev then

%p return k-1;

%p end if;

%p prev := this ;

%p end do:

%p end proc:

%p seq(A249160(n),n=1..80) ; # _R. J. Mathar_, Nov 17 2014

%t r[n_]:=Ceiling[Sqrt[n]]^2-n;Table[Length[FixedPointList[r,n]]-2,{n,1,100}]

%o (PARI) r(n)=if(issquare(n),0,(sqrtint(n)+1)^2-n);

%o le(n)=b=0;while(n!=0&&n!=2,b=b+1;n=r(n));return(b);

%o range(n) = c=List(); for(a = 1, n, listput(c,a)); return(c);

%o apply(le, range(100))

%Y Cf. A068527.

%K nonn,easy

%O 1,3

%A _Valtteri Raiko_, Oct 22 2014