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.
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
Keywords
Links
- Michel Marcus, Table of n, a(n) for n = 1..10000
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.
Comments