login
A038760
a(n) = n - floor(sqrt(n)) * ceiling(sqrt(n)).
5
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,9
LINKS
FORMULA
a(n) = n - A000196(n)*A003059(n) = n - A038759(n).
EXAMPLE
Sqrt(31) is between 5 and 6, and 31 - 6*5 = 1, so a(31)=1.
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 *)
PROG
(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
CROSSREFS
Cf. A053188.
Sequence in context: A036580 A101674 A100820 * A337938 A245825 A143946
KEYWORD
sign,easy
AUTHOR
Henry Bottomley, May 03 2000
STATUS
approved