login
a(n) = sqrt(n) of n if n is a perfect square, otherwise a(n) = largest term in period of continued fraction expansion of square root of n.
7

%I #17 Aug 07 2024 15:11:35

%S 1,2,2,2,4,4,4,4,3,6,6,6,6,6,6,4,8,8,8,8,8,8,8,8,5,10,10,10,10,10,10,

%T 10,10,10,10,6,12,12,12,12,12,12,12,12,12,12,12,12,7,14,14,14,14,14,

%U 14,14,14,14,14,14,14,14,14,8,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16

%N a(n) = sqrt(n) of n if n is a perfect square, otherwise a(n) = largest term in period of continued fraction expansion of square root of n.

%e For n=127: the period={3,1,2,2,7,11,7,2,2,1,3,22}, max=a(127)=22.

%p A096491 := proc(n)

%p if issqr(n) then

%p sqrt(n) ;

%p else

%p numtheory[cfrac](sqrt(n),'periodic','quotients') ;

%p %[2] ;

%p max(op(%)) ;

%p end if;

%p end proc:

%p # _R. J. Mathar_, Mar 18 2010

%t u=1;Do[s=Max[Last[ContinuedFraction[n^(1/2)]]];tc[[u]]=s;u=u+1, {n, 1, m}]

%Y Cf. A003285, A013646.

%K nonn

%O 1,2

%A _Labos Elemer_, Jun 29 2004

%E Definition revised by _N. J. A. Sloane_, Mar 18 2010