login
A124601
Position of the first 1 in the decimal expansion of the square root of n, or -1 if 1 never appears.
1
-1, 1, 1, 1, -1, 23, 14, 7, 8, -1, 2, 3, 5, 7, 4, 15, -1, 2, 11, 25, 5, 26, 6, 7, 17, -1, 6, 2, 4, 5, 13, 16, 17, 24, 7, 3, -1, 15, 2, 26, 41, 5, 57, 23, 12, 25, 11, 13, 17, -1, 4, 2, 3, 5, 22, 3, 6, 32, 3, 4, 12, 3, 12, 11, -1, 24, 2, 2, 6, 12, 22, 5, 7, 12, 19, 25, 3, 14, 4, 5, 7
OFFSET
0,6
LINKS
EXAMPLE
For n=5, the concatenated digits of sqrt(5) are 223606797749978969640917366... The digit 1 first occurs in the 23rd position of this string of digits. So 23 is the 6th entry in the table counting from the 0th entry.
MAPLE
f:= proc(n) local x, s, j, k;
if issqr(n) then
s:= convert(sqrt(n), base, 10);
for j from 1 to nops(s) do
if s[-j] = 1 then return j fi
od;
return -1
fi;
x:= n/100^ilog[100](n);
s:= floor(sqrt(x));
if s = 1 then return 1 fi;
for j from 2 do
x:= 100*x;
for k from 1 to 10 do
if (10*s+k)^2 > x then
if k = 2 then return j fi;
s:= 10*s+k-1;
break
fi;
od;
od
end proc;
map(f, [$0..100]); # Robert Israel, Jan 25 2026
PROG
(PARI)
finddig(n, x)={my(d=digits(n)); for(i=1, #d, if(d[i]==x, return(i))); -1}
a(n) = {if(issquare(n), finddig(sqrtint(n), 1), my(m=2, z=-1); while(z<0, z=finddig(sqrtint(n*100^m), 1); m*=2); z)} \\ Andrew Howroyd, Jan 25 2026
CROSSREFS
Sequence in context: A064735 A384439 A104958 * A040508 A305943 A318090
KEYWORD
base,easy,sign
AUTHOR
Cino Hilliard, Dec 22 2006, corrected Jul 18 2007
STATUS
approved