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.

A327898 a(n) is the nearest integer to the reciprocal of the difference between the square root of n and the nearest integer to this square root unless n is a perfect square, in which case a(n) equals 0.

Original entry on oeis.org

0, 2, -4, 0, 4, 2, -3, -6, 0, 6, 3, 2, -3, -4, -8, 0, 8, 4, 3, 2, -2, -3, -5, -10, 0, 10, 5, 3, 3, 2, -2, -3, -4, -6, -12, 0, 12, 6, 4, 3, 2, 2, -2, -3, -3, -5, -7, -14, 0, 14, 7, 5, 4, 3, 2, 2, -2, -3, -3, -4, -5, -8, -16, 0, 16, 8, 5, 4, 3, 3, 2, 2, -2, -3
Offset: 1

Views

Author

Sebastian F. Orellana, Sep 29 2019

Keywords

Comments

If n is a perfect square, i.e., 1, 4, 9, or 16, then the computation is not possible and a(n) is given as 0.

Crossrefs

Cf. A000290 (squares), A013942, A091453 (if floor is used instead of round).

Programs

  • Mathematica
    Array[If[IntegerQ@ #2, 0, Round[1/(#2 - Round[#2])]] & @@ {#, Sqrt@ #} &, 64] (* Michael De Vlieger, Sep 29 2019 *)
  • PARI
    a(n)={if(issquare(n), 0, my(t=sqrt(n)); round(1/(t-round(t))))} \\ Andrew Howroyd, Sep 30 2019

Formula

a(n) = round(1/(sqrt(n)-round(sqrt(n)))) for n not a square; a(n) = 0 otherwise.