J, 14 chars
This is just hardcoding the [1,2, 4+3*k (k=0..n) ]
sequence and takes the first N
.
({.1,2,4+3*i.) 10
1 2 4 7 10 13 16 19 22 25
. J, 18 chars
This one uses the linear combination of [0,1,2,3...]
, [1,1,0,0...]
and [0,1,1,1...]
.
Should be shorter but can't seem to golf it.
((3&*+<&2-2**)@i.) 10
1 2 4 7 10 13 16 19 22 25