login
Take the first odd integer and multiple of 1, the next 2 even integers and multiples of 2, the next 3 odd integers and multiples of 3, the next 4 even integers and multiples of 4, ...
6

%I #19 Jan 29 2022 01:19:25

%S 1,2,4,9,15,21,24,28,32,36,45,55,65,75,85,90,96,102,108,114,120,133,

%T 147,161,175,189,203,217,224,232,240,248,256,264,272,280,297,315,333,

%U 351,369,387,405,423,441,450,460,470,480,490,500,510,520,530,540,561,583,605,627,649,671,693

%N Take the first odd integer and multiple of 1, the next 2 even integers and multiples of 2, the next 3 odd integers and multiples of 3, the next 4 even integers and multiples of 4, ...

%C A generalized Connell sequence.

%H Reinhard Zumkeller, <a href="/A045975/b045975.txt">Rows n=1..150 of triangle, flattened</a>

%e Triangle begins:

%e 1;

%e 2, 4;

%e 9, 15, 21;

%e 24, 28, 32, 36;

%e 45, 55, 65, 75, 85;

%e 90, 96, 102, 108, 114, 120;

%e 133, 147, 161, 175, 189, 203, 217;

%e ...

%t first[n_?EvenQ] := (n - 1)*n^2/2; first[n_?OddQ] := n*(n^2 - 2n + 3)/2; row[n_] := (ro = {first[n]}; next = first[n] + n; While[ Length[ro] < n, If[Mod[next , 2] == Mod[n, 2], AppendTo[ro, next]]; next = next + n]; ro); Flatten[ Table[row[n], {n, 1, 11}]](* _Jean-François Alcover_, Jun 08 2012 *)

%o (Haskell)

%o a045975 n k = a045975_tabl !! (n-1) !! (k-1)

%o a045975_row n = a045975_tabl !! (n-1)

%o a045975_tabl = f 1 [1..] where

%o f k xs = ys : f (k+1) (dropWhile (<= last ys) xs) where

%o ys | even k = take k ms

%o | otherwise = take k $ filter odd ms

%o ms = filter ((== 0) . (`mod` k)) xs

%o -- _Reinhard Zumkeller_, Jan 18 2012

%Y Cf. A001614, A033291.

%Y Seen as a triangle read by rows: cf. A204558 (row sums), A005917 (central terms), A204556 (left edge), A204557 (right edge).

%K nonn,easy,nice,tabl

%O 1,2

%A Fang-kuo Huang (gsyps(AT)ms17.hinet.net)

%E More terms from _James A. Sellers_

%E Keyword tabl added by _Reinhard Zumkeller_, Jan 18 2012