[go: up one dir, main page]

login
A066635
Distance from n to closest square different from n.
6
1, 1, 1, 3, 1, 2, 2, 1, 5, 1, 2, 3, 3, 2, 1, 7, 1, 2, 3, 4, 4, 3, 2, 1, 9, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 11, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 13, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 15, 1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1, 17, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 19, 1, 2
OFFSET
1,4
COMMENTS
The oscillatory nature of the sequence with increasing amplitude is quite evident.
LINKS
FORMULA
a(n) = Min {n - floor(sqrt(n))^2, (floor(sqrt(n))+1)^2 - n} if n is not a square. a(n) = 2*sqrt(n) - 1 if n is a square.
G.f.: -x^2/(1-x)^2 + Sum_{m>=1} x^(m^2)*(2m - x^m*(x+x^2)/(1-x)^2 -(1-4*x+x^2)/(1-x)^2). - Robert Israel, Nov 07 2017
EXAMPLE
a(11) = 2 as 11 is closer to 9 than to 16 and 11 - 9 = 2.
MAPLE
N:= 10: # to get a(1)..a((N+1)^2-1)
seq(op([m^2-(m-1)^2, seq(i-m^2, i=m^2+1..m^2+m), seq((m+1)^2-i, i=m^2+m+1..(m+1)^2-1)]), m=1..N); # Robert Israel, Nov 07 2017
CROSSREFS
Sequence in context: A222593 A107033 A115110 * A016568 A327314 A021888
KEYWORD
easy,nonn,look
AUTHOR
Amarnath Murthy, Dec 29 2001
EXTENSIONS
More terms from Larry Reeves (larryr(AT)acm.org), Apr 03 2002
STATUS
approved