login
Least number k > n such that n concatenated with k is a perfect square.
4

%I #39 Sep 01 2023 11:48:27

%S 1,6,5,6,9,29,25,29,41,61,24,56,25,69,44,21,81,64,49,36,25,316,201,

%T 104,336,281,244,225,224,241,276,36,49,64,81,344,100,249,44,69,96,209,

%U 436,56,89,369,225,61,400,284,176,84,441,361,76,225,169,76,564,536,84,504,500,504,516,536

%N Least number k > n such that n concatenated with k is a perfect square.

%C Records occur at: 0, 1, 4, 5, 8, 9, 13, 16, 21, 24, 35, 42, 52, 58, 67, 75, 80, ..., . - _Robert G. Wilson v_, Nov 23 2015

%H Robert G. Wilson v, <a href="/A243091/b243091.txt">Table of n, a(n) for n = 0..1000</a>

%e a(1) = 6 since 6>1 and 16 = 4^2.

%e a(2) = 5 since 5>2 and 25 = 5^2.

%t f[n_] := Block[{x = n, d = 1 + Floor@ Log10@ n}, q = (Floor@ Sqrt[(10^d + 1) x] + 1)^2; If[q < (10^d) (x + 1), Mod[q, 10^d], Mod[(Floor@ Sqrt[(10^d) (10 x + 1) - 1] + 1)^2, 10^(d + 1)]]]; Array[f, 65] (* _Robert G. Wilson v_, Nov 23 2015, after the algorithm of _David W. Wilson_ in A090566 *)

%t lnk[n_]:=Module[{k=n+1},While[!IntegerQ[Sqrt[n 10^IntegerLength[k]+k]],k++];k]; Array[lnk,70,0] (* _Harvey P. Dale_, Sep 01 2023 *)

%o (PARI) a(n)=s=Str(n); k=n+1; while(!issquare(eval(concat(s,Str(k)))), k++); return(k)

%o vector(100, n, a(n))

%o (PARI) A048761 = t->(sqrtint(t-1)+1)^2

%o A243091(n)={my(d=#Str(n),a=A048761((1+10^d)*n)); a>=(n+1)*10^d && a=A048761((n*10+1)*10^d); a%10^(d+(a>=100^d))} \\ _M. F. Hasler_, Nov 24 2015

%Y Cf. A090566.

%K nonn,base

%O 0,2

%A _Derek Orr_, Aug 18 2014

%E a(0)=1 added by _N. J. A. Sloane_, Nov 24 2015