A001670 k appears k times (k even).
2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
Offset: 1
Links
- Vincenzo Librandi, Table of n, a(n) for n = 1..10000
Programs
-
MATLAB
a = @(n) 2*floor((sqrt(4*n-3)+1)/2); % Néstor Jofré, Apr 24 2017
-
Magma
[2*Round(Sqrt(n)): n in [1..70]]; // Vincenzo Librandi, Jun 23 2011
-
Maple
seq(2*n $ 2*n, n = 1 .. 10); # Robert Israel, Jan 14 2015
-
Mathematica
a[1]=2, a[2]=2, a[n_]:=a[n]=a[n-a[n-2]]+2 (* Branko Curgus, May 11 2010 *) Flatten[Table[Table[n,{n}],{n,2,16,2}]] (* Harvey P. Dale, May 31 2012 *)
-
PARI
a(n)=round(sqrt(n))<<1 \\ Charles R Greathouse IV, Jun 23 2011
-
Python
from math import isqrt def A001670(n): return (m:=isqrt(n))+int((n-m*(m+1)<<2)>=1)<<1 # Chai Wah Wu, Jul 29 2022
Formula
a(n) = 2*floor(1/2 + sqrt(n)). - Antonio Esposito, Jan 21 2002; corrected by Branko Curgus, May 11 2010
With a different offset: g.f. = Sum_{j>=0} 2*x^(j^2+i)/(1-x). - Ralf Stephan, Mar 11 2003
From Branko Curgus, May 11 2010: (Start)
a(n) = a(n - a(n-2)) + 2; a(1)=2, a(2)=2.
a(n) = 2*round(sqrt(n)). (End)
G.f.: x^(3/4)*theta_2(0,x)/(1-x) where theta_2 is the second Jacobi theta function. - Robert Israel, Jan 14 2015
a(n) = 2*floor((sqrt(4*n-3)+1)/2). - Néstor Jofré, Apr 24 2017
Extensions
Offset changed from 2 to 1 by Vincenzo Librandi, Jun 23 2011