|
|
A018796
|
|
Smallest square that begins with n.
|
|
18
|
|
|
0, 1, 25, 36, 4, 529, 64, 729, 81, 9, 100, 1156, 121, 1369, 144, 1521, 16, 1764, 1849, 196, 2025, 2116, 225, 2304, 2401, 25, 2601, 2704, 289, 2916, 3025, 3136, 324, 3364, 3481, 35344, 36, 3721, 3844, 3969, 400, 41209, 4225, 4356, 441, 45369, 4624, 4761, 484, 49
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
If 4*(n+1) < 10^d then a(n) < (n+1)*10^d. - Robert Israel, Aug 01 2014
|
|
LINKS
|
|
|
EXAMPLE
|
Among the first 100001 terms, the largest is a(99999) = 99999515529 = 316227^2. - Zak Seidov, May 22 2016
|
|
MAPLE
|
a:= proc(n) local k, d, x;
if issqr(n) then return n
else for d from 1 do
for k from 0 to 10^d-1 do
x:= 10^d*n+k;
if issqr(x) then return x fi
od
od
fi
end proc:
|
|
MATHEMATICA
|
Table[With[{d = IntegerDigits@ n}, k = 1; While[Or[IntegerLength[k^2] < Length@ d, Take[IntegerDigits[k^2], Length@ d] != d], k++]; k^2], {n, 49}] (* Michael De Vlieger, May 23 2016 *)
|
|
PROG
|
(Python)
n = 1
while n < 100:
for k in range(10**3):
if str(k**2).startswith(str(n)):
print(k**2, end=', ')
break
(Python)
from gmpy2 import isqrt
if n == 0:
return 0
else:
d, nd = 1, n
while True:
x = (isqrt(nd-1)+1)**2
if x < nd+d:
return int(x)
d *= 10
(PARI) \\Set precision high enough (for the cases where n+1 is a square)!
a(n) = {my(v=vector(2)); if(issquare(n), return(n), v=[sqrt(n), sqrt(n+1-(10^-((#digits(n)+7))))]; while(ceil(v[1])>floor(v[2]), v*=sqrt(10))); ceil(v[1])^2
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base,easy
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|