login
Smallest k such that the concatenation of n and k is a square (decimal notation).
6

%I #28 Sep 03 2023 10:38:07

%S 6,5,6,9,29,4,29,1,61,0,56,1,69,4,21,9,64,49,6,25,16,5,104,336,6,244,

%T 225,9,16,25,36,4,64,81,344,1,21,44,69,0,209,25,56,1,369,24,61,4,284,

%U 41,84,9,29,76,225,25,6,564,29,84,504,5,504

%N Smallest k such that the concatenation of n and k is a square (decimal notation).

%C a(n) = 1 correspond to n = A132356(m), m > 0. - _Bill McEachen_, Aug 31 2023

%H Reinhard Zumkeller, <a href="/A071176/b071176.txt">Table of n, a(n) for n = 1..10000</a>

%F A000196(n . a(n)) = A071177(n) where "." stands for concatenation.

%e a(5) = 29 as 529 = 23^2 and 5'i is nonsquare for i<29, A071177(5)=23.

%t nksq[n_]:=Module[{idn=IntegerDigits[n],k=0},While[!IntegerQ[Sqrt[ FromDigits[Join[ idn,IntegerDigits[k]]]]],k++];k]; Array[nksq,70] (* _Harvey P. Dale_, Sep 28 2012 *)

%o (Haskell)

%o import Data.List (findIndex)

%o import Data.Maybe (fromJust)

%o a071176 n = fromJust $ findIndex (== 1) $

%o map (a010052 . read . (show n ++) . show) [0..]

%o -- _Reinhard Zumkeller_, Aug 09 2011

%o (PARI) a(n)={if(issquare(10*n), 0, my(m=n, b=1); while(1, m*=10; my(r=(sqrtint(m+b-1)+1)^2-m); b*=10; if(r<b, return(r))))} \\ _Andrew Howroyd_, Jan 13 2023

%o (Python)

%o from math import isqrt

%o from sympy.ntheory.primetest import is_square

%o def A071176(n):

%o m = 10*n

%o if is_square(m): return 0

%o a = 1

%o while (k:=(isqrt(a*(m+1)-1)+1)**2-m*a)>=10*a:

%o a *= 10

%o return k # _Chai Wah Wu_, Feb 15 2023

%Y Cf. A000196, A071177, A245631, A132356.

%K nonn,base,nice,look

%O 1,1

%A _Reinhard Zumkeller_, May 15 2002