login
Difference between smallest square >= n and n.
27

%I #31 Sep 08 2022 08:45:05

%S 0,0,2,1,0,4,3,2,1,0,6,5,4,3,2,1,0,8,7,6,5,4,3,2,1,0,10,9,8,7,6,5,4,3,

%T 2,1,0,12,11,10,9,8,7,6,5,4,3,2,1,0,14,13,12,11,10,9,8,7,6,5,4,3,2,1,

%U 0,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,18,17,16,15,14,13,12,11,10,9

%N Difference between smallest square >= n and n.

%C The greedy inverse (sequence of the smallest k such that a(k)=n) starts 0, 3, 2, 6, 5, 11, 10, 18, 17, 27, 26, 38, 37, 51, 50, ... and appears to be given by A010000 and A002522, interleaved. - _R. J. Mathar_, Nov 17 2014

%H Ivan Panchenko, <a href="/A068527/b068527.txt">Table of n, a(n) for n = 0..1000</a>

%F a(n) = A048761(n) - n = ceiling(sqrt(n))^2 - n.

%F G.f.: (-x^2 + (x-x^2)*Sum_{m>=1} (1+2*m)*x^(m^2))/(1-x)^2. This sum is related to Jacobi Theta functions. - _Robert Israel_, Nov 17 2014

%p A068527:=n->ceil(sqrt(n))^2-n; seq(A068527(n), n=0..100); # _Wesley Ivan Hurt_, Jun 11 2014

%t Table[Ceiling[Sqrt[n]]^2-n,{n,0,100}] (* _Vladimir Joseph Stephan Orlovsky_, Feb 01 2012 *)

%o (Magma) [ Ceiling(Sqrt(n))^2-n : n in [0..50] ]; // _Wesley Ivan Hurt_, Jun 11 2014

%o (PARI) a(n)=if(issquare(n), 0, (sqrtint(n)+1)^2-n) \\ _Charles R Greathouse IV_, Oct 22 2014

%o (Python)

%o from math import isqrt

%o def A068527(n): return 0 if n == 0 else (isqrt(n-1)+1)**2-n # _Chai Wah Wu_, Feb 22 2022

%Y Cf. A053186, A068869, A066857.

%Y Bisections: A348596, A350962.

%K nonn,easy

%O 0,3

%A _Vladeta Jovovic_, Mar 21 2002