OFFSET
0,3
LINKS
Robert Israel, Table of n, a(n) for n = 0..10000
MAPLE
f:= proc(n) uses StringTools; local d, S, r;
if issqr(n) then
S:= convert(sqrt(n), string);
r:= Search("5", S);
if r = 0 then -1 else r fi
else
d:= 10:
do
S:= convert(floor(10^d*sqrt(n)), string);
r:= Search("5", S);
if r > 0 then return r fi;
d:= 2*d;
od;
fi
end proc:
map(f, [$0..100]); # Robert Israel, May 19 2019
PROG
(PARI) digitpos(n, m) = /* m-th digit in sqrt expansions */ { local(x, y, r, dot); default(realprecision, 1000); for(x=0, n, r = sqrt(x); if(issquare(x), y=find(Str(floor(r)), m), y=find(Str(r), m); dot=find(Str(r), "."); if(dot < y, y--); ); if(y, print1(y", "), print1(-1", ") ) ) }
find(str, match) = /* Revised 2007 */ { local(lnm, lns, tstr, vstr, x, j); vstr=Vec(Str(str)); match=Str(match); lns=length(str); lnm=length(match); for(x=1, lns-lnm+1, tstr=""; for(j=x, x+lnm-1, tstr=concat(tstr, vstr[j]); ); if(match==tstr, return(x)) ); return(0); }
CROSSREFS
KEYWORD
AUTHOR
Cino Hilliard, Dec 22 2006, corrected Jul 18 2007
STATUS
approved