login
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.
2
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,2
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.
LINKS
FORMULA
a(n) = round(1/(sqrt(n)-round(sqrt(n)))) for n not a square; a(n) = 0 otherwise.
MATHEMATICA
Array[If[IntegerQ@ #2, 0, Round[1/(#2 - Round[#2])]] & @@ {#, Sqrt@ #} &, 64] (* Michael De Vlieger, Sep 29 2019 *)
PROG
(PARI) a(n)={if(issquare(n), 0, my(t=sqrt(n)); round(1/(t-round(t))))} \\ Andrew Howroyd, Sep 30 2019
CROSSREFS
Cf. A000290 (squares), A013942, A091453 (if floor is used instead of round).
Sequence in context: A338475 A134352 A152648 * A140875 A364315 A115368
KEYWORD
sign
AUTHOR
STATUS
approved