OFFSET
1,1
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 1..10000
FORMULA
1 <= a(n) <= 2*sqrt(n) + 2. - Charles R Greathouse IV, Mar 23 2015
a(n) = (1/4)*(6*floor(sqrt(n)) + 2*floor(sqrt(n))^2 + (2*floor(sqrt(n)) + 3)*(-1)^(n - floor(sqrt(n))) - 2*n + 5). - Ridouane Oudra, Oct 09 2020
EXAMPLE
1 + 2*4 = 9 = 3^2 so a(1) = 4.
2 + 2*1 = 4 = 2^2, so a(2) = 1.
3 + 2*3 = 9 = 3^2, so a(3) = 3.
MATHEMATICA
Table[m = 1; While[! IntegerQ[Sqrt[n + 2*m]], m++]; m, {n, 100}] (* Michael De Vlieger, Mar 20 2015 *)
PROG
(PARI) a(n)=m=1; while(!issquare(n+2*m), m++); m
vector(100, n, a(n)) \\ Derek Orr, Mar 22 2015
(PARI) a(n)=my(s=sqrtint(n)); (if((s-n)%2, s+1, s+2)^2-n)/2 \\ Charles R Greathouse IV, Mar 23 2015
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Zak Seidov, Mar 20 2015
STATUS
approved