%I #42 Aug 29 2023 04:23:23
%S 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,
%T 10,12,12,12,12,12,12,12,12,12,12,12,12,14,14,14,14,14,14,14,14,14,14,
%U 14,14,14,14,16,16,16,16,16,16,16,16,16,16,16,16,16,16
%N k appears k times (k even).
%H Vincenzo Librandi, <a href="/A001670/b001670.txt">Table of n, a(n) for n = 1..10000</a>
%F a(n) = 2*floor(1/2 + sqrt(n)). - _Antonio Esposito_, Jan 21 2002; corrected by _Branko Curgus_, May 11 2010
%F With a different offset: g.f. = Sum_{j>=0} 2*x^(j^2+i)/(1-x). - _Ralf Stephan_, Mar 11 2003
%F From _Branko Curgus_, May 11 2010: (Start)
%F a(n) = a(n - a(n-2)) + 2; a(1)=2, a(2)=2.
%F a(n) = 2*round(sqrt(n)). (End)
%F 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
%F a(n) = 2*floor((sqrt(4*n-3)+1)/2). - _Néstor Jofré_, Apr 24 2017
%p seq(2*n $ 2*n, n = 1 .. 10); # _Robert Israel_, Jan 14 2015
%t a[1]=2, a[2]=2, a[n_]:=a[n]=a[n-a[n-2]]+2 (* _Branko Curgus_, May 11 2010 *)
%t Flatten[Table[Table[n,{n}],{n,2,16,2}]] (* _Harvey P. Dale_, May 31 2012 *)
%o (Magma) [2*Round(Sqrt(n)): n in [1..70]]; // _Vincenzo Librandi_, Jun 23 2011
%o (PARI) a(n)=round(sqrt(n))<<1 \\ _Charles R Greathouse IV_, Jun 23 2011
%o (MATLAB) a = @(n) 2*floor((sqrt(4*n-3)+1)/2); % handle function // _Néstor Jofré_, Apr 24 2017
%o (Python)
%o from math import isqrt
%o def A001670(n): return (m:=isqrt(n))+int((n-m*(m+1)<<2)>=1)<<1 # _Chai Wah Wu_, Jul 29 2022
%Y Cf. A001650, A000194.
%Y Equals A130829(n) - 1.
%K nonn,easy
%O 1,1
%A _N. J. A. Sloane_
%E Offset changed from 2 to 1 by _Vincenzo Librandi_, Jun 23 2011