login
Position of the first 0 in the decimal expansion of the square root of n, or -1 if 0 never appears.
1

%I #16 Dec 18 2024 21:02:19

%S 1,-1,14,5,-1,5,17,11,16,-1,10,10,6,3,36,12,-1,6,7,13,37,16,4,26,52,

%T -1,2,12,6,9,11,13,16,14,4,5,-1,2,8,18,10,3,4,12,10,3,20,9,6,-1,2,48,

%U 6,4,49,11,32,13,9,15,19,4,5,21,-1,2,5,24,17,3,6,19,16,5,3,4,11,17,7,19,9

%N Position of the first 0 in the decimal expansion of the square root of n, or -1 if 0 never appears.

%C The real 0's representations after the decimal point of the expansion of the square root of perfect squares are ignored. In other words for sqrt(4) = 2.0000..., the trailing 0's are ignored.

%H Andrew Howroyd, <a href="/A124600/b124600.txt">Table of n, a(n) for n = 0..1000</a>

%e For n=14, the concatenated digits of sqrt(14) are The digit 0 in the 36th position of this string of digits so 36 is the 15th entry the table counting from the 0th entry.

%t Join[{1},Table[If[IntegerQ[Sqrt[n]],{{-1,-1}},SequencePosition[ RealDigits[ Sqrt[n],10,100][[1]],{0},1]],{n,100}][[All,1]][[All,1]]] (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, Oct 02 2016 *)

%o (PARI) a(n)={if(n==0, 1, forstep(m=0, oo, 10, my(z=select(x->x==0, digits(sqrtint(100^m*n)), 1)); if(#z, return(z[1])); if(!m&&issquare(n),return(-1)) ))} \\ _Andrew Howroyd_, Dec 18 2024

%K base,easy,sign

%O 0,3

%A _Cino Hilliard_, Dec 22 2006, corrected Jul 18 2007