cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A038760 a(n) = n - floor(sqrt(n)) * ceiling(sqrt(n)).

Original entry on oeis.org

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

Views

Author

Henry Bottomley, May 03 2000

Keywords

Examples

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

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

Formula

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