A038760 a(n) = n - floor(sqrt(n)) * ceiling(sqrt(n)).
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, -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, 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
Offset: 0
Examples
Sqrt(31) is between 5 and 6, and 31 - 6*5 = 1, so a(31)=1.
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..10000
Crossrefs
Cf. A053188.
Programs
-
Maple
a:= n-> n -(x-> floor(x)*ceil(x))(sqrt(n)): seq(a(n), n=0..100); # Alois P. Heinz, Jan 03 2015
-
Mathematica
f[n_]:=n-Floor[Sqrt[n]]*Ceiling[Sqrt[n]];Table[f[n],{n,0,5!}] (* Vladimir Joseph Stephan Orlovsky, Mar 29 2010 *)
-
PARI
a(n)=if(issquare(n),0,my(s=sqrtint(n));n-s^2-s) \\ Charles R Greathouse IV, Feb 07 2013
-
Python
from math import isqrt def A038760(n): return m-k if (m:=n-(k:=isqrt(n))**2) else 0 # Chai Wah Wu, Jul 28 2022
Comments