OFFSET
1,11
COMMENTS
Record values: given an m>=0, the first n for which a(n)=m is n = (m+1)^2+m = A028387(m). Also, for n>3, n is a square if and only if a(n)=0 and a(n-1)=0. - Stanislav Sykora, Aug 13 2014
LINKS
Stanislav Sykora, Table of n, a(n) for n = 1..1023
FORMULA
a(n) = 0 if n or n+1 or 4*n+1 is a square, otherwise a(n) = a(n-1)+1. - Robert Israel, Aug 13 2014
G.f.: sum(r=2..infinity, x^(r^2) * (x^r + 1) * ((r-1)*x^(r+1) - r*x^r + x)/(1 - x)^2. - Robert Israel, Aug 13 2014
MAPLE
a:= proc(n) local r;
r:= isqrt(n);
if r^2 > n then r:= r-1 fi;
n mod r;
end proc:
seq(a(n), n=1..100); # Robert Israel, Aug 13 2014
MATHEMATICA
Table[Mod[n, Floor[Sqrt[n]]], {n, 110}] (* Harvey P. Dale, Apr 10 2016 *)
PROG
(PARI) a(n)=n%sqrtint(n)
CROSSREFS
KEYWORD
nonn
AUTHOR
Benoit Cloitre, Jan 31 2003
STATUS
approved