|
|
A004202
|
|
Skip 1, take 1, skip 2, take 2, skip 3, take 3, etc.
|
|
13
|
|
|
2, 5, 6, 10, 11, 12, 17, 18, 19, 20, 26, 27, 28, 29, 30, 37, 38, 39, 40, 41, 42, 50, 51, 52, 53, 54, 55, 56, 65, 66, 67, 68, 69, 70, 71, 72, 82, 83, 84, 85, 86, 87, 88, 89, 90, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132
(list;
table;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,1
|
|
COMMENTS
|
a(n) are the numbers satisfying m < sqrt(a(n)) < m + 0.5 for some integer m. - Floor van Lamoen, Jul 24 2001
|
|
LINKS
|
|
|
FORMULA
|
T(n, k) = n^2 + k, for n>=1, k>=1 as a triangular array. a(n) = n + A127739(n). - Michael Somos, May 03 2019
|
|
EXAMPLE
|
s = (1,2,2,3,3,3,4,4,4,4...) = A002024 (n n's);
a = (1,3,4,7,8,9,13,14,...) = A004201 = least number > 0 not yet in a or b;
b = (2,5,6,10,11,12,17,18,...) = A004202 = a+s.
As a triangular array
2;
5, 6;
10, 11, 12;
17, 18, 19, 20;
(End)
|
|
MATHEMATICA
|
a = Table[n, {n, 1, 210} ]; b = {}; Do[a = Drop[a, {1, n} ]; b = Append[b, Take[a, {1, n} ]]; a = Drop[a, {1, n} ], {n, 1, 14} ]; Flatten[b]
a[ n_] := If[ n < 1, 0, With[{m = Round@Sqrt[2 n]}, n + m (m + 1)/2]]; (* Michael Somos, May 03 2019 *)
Take[#, (-Length[#])/2]&/@Module[{nn=20}, TakeList[Range[ nn+nn^2], 2*Range[ nn]]]//Flatten (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, May 13 2019 *)
|
|
PROG
|
(Haskell)
a004202 n = a004202_list !! (n-1)
a004202_list = skipTake 1 [1..] where
skipTake k xs = take k (drop k xs) ++ skipTake (k + 1) (drop (2*k) xs)
(PARI) {a(n) = my(m); if( n<1, 0, m=round(sqrt(2*n)); n + m*(m+1)/2)}; /* Michael Somos, May 03 2019 */
(Python)
from math import isqrt, comb
def A004202(n): return n+comb((m:=isqrt(k:=n<<1))+(k-m*(m+1)>=1)+1, 2) # Chai Wah Wu, Jun 19 2024
|
|
CROSSREFS
|
|
|
KEYWORD
|
|
|
AUTHOR
|
Alexander Stasinski
|
|
STATUS
|
approved
|
|
|
|