login
a(n) = n - floor(sqrt(n)) * ceiling(sqrt(n)).
5

%I #20 Jul 28 2022 15:18:56

%S 0,0,0,1,0,-1,0,1,2,0,-2,-1,0,1,2,3,0,-3,-2,-1,0,1,2,3,4,0,-4,-3,-2,

%T -1,0,1,2,3,4,5,0,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,0,-6,-5,-4,-3,-2,-1,0,

%U 1,2,3,4,5,6,7,0,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,0,-8,-7,-6,-5,-4

%N a(n) = n - floor(sqrt(n)) * ceiling(sqrt(n)).

%H Alois P. Heinz, <a href="/A038760/b038760.txt">Table of n, a(n) for n = 0..10000</a>

%F a(n) = n - A000196(n)*A003059(n) = n - A038759(n).

%e Sqrt(31) is between 5 and 6, and 31 - 6*5 = 1, so a(31)=1.

%p a:= n-> n -(x-> floor(x)*ceil(x))(sqrt(n)):

%p seq(a(n), n=0..100); # _Alois P. Heinz_, Jan 03 2015

%t f[n_]:=n-Floor[Sqrt[n]]*Ceiling[Sqrt[n]];Table[f[n],{n,0,5!}] (* _Vladimir Joseph Stephan Orlovsky_, Mar 29 2010 *)

%o (PARI) a(n)=if(issquare(n),0,my(s=sqrtint(n));n-s^2-s) \\ _Charles R Greathouse IV_, Feb 07 2013

%o (Python)

%o from math import isqrt

%o def A038760(n): return m-k if (m:=n-(k:=isqrt(n))**2) else 0 # _Chai Wah Wu_, Jul 28 2022

%Y Cf. A053188.

%K sign,easy

%O 0,9

%A _Henry Bottomley_, May 03 2000