OFFSET
1,2
COMMENTS
a(n) are the numbers satisfying m - 0.5 < sqrt(a(n)) <= m for some positive integer m. - Floor van Lamoen, Jul 24 2001
LINKS
Harvey P. Dale, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = A061885(n-1)+1. - Franklin T. Adams-Watters, Jul 05 2009
a(n+1) - a(n) = A130296(n+1). - Reinhard Zumkeller, Jul 16 2008
a(A000217(n)) = n^2. - Reinhard Zumkeller, Feb 12 2011
a(n) = n + t(t+1)/2, where t = floor((-1+sqrt(8*n-7))/2). - Boris Putievskiy, Dec 13 2012
a(n) = (2*n - r + r^2)/2, where r = round(sqrt(2*n)). - Wesley Ivan Hurt, Sep 20 2021
MATHEMATICA
f[x_]:=Module[{c=1-x+x^2}, Range[c, c+x-1]]; Flatten[Array[f, 20]] (* Harvey P. Dale, Jul 31 2012 *)
PROG
(Haskell)
a004201 n = a004201_list !! (n-1)
a004201_list = f 1 [1..] where
f k xs = us ++ f (k + 1) (drop (k) vs) where (us, vs) = splitAt k xs
-- Reinhard Zumkeller, Jun 20 2015, Feb 12 2011
(PARI) A004201(n)=n+(n=(sqrtint(8*n-7)+1)\2)*(n-1)\2 \\ M. F. Hasler, Feb 13 2011
(Python)
from math import comb, isqrt
def A004201(n): return n+comb((m:=isqrt(k:=n<<1))+(k>m*(m+1)), 2) # Chai Wah Wu, Nov 09 2024
CROSSREFS
KEYWORD
nonn,nice
AUTHOR
Alexander Stasinski
STATUS
approved