login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
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

Zak Seidov, Table of n, a(n) for n = 0..100000, May 22 2016 (first 10000 terms from Chai Wah Wu)

EXAMPLE

Among 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:

seq(a(n), n=1..100); # Robert Israel, Jul 31 2014

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

    n += 1 # Derek Orr, Jul 31 2014

(Python)

from gmpy2 import isqrt

def A018796(n):

    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

            nd *= 10 # Chai Wah Wu, May 23 2016

(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

} \\ David A. Corneth, May 22 2016

CROSSREFS

Cf. A018851, A077502.

Sequence in context: A068165 A086935 A077689 * A029945 A264906 A263095

Adjacent sequences:  A018793 A018794 A018795 * A018797 A018798 A018799

KEYWORD

nonn,base,easy

AUTHOR

David W. Wilson

EXTENSIONS

a(0)=0  prepended by Zak Seidov, May 22 2016

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified January 16 14:59 EST 2022. Contains 350376 sequences. (Running on oeis4.)