Hypercube elements
J, 13 bytes
[:p.2&^;$&_.5
Inspired by @alephalpha's PARI/GP answer. Try it online with J.js.
Background
By the binomial theorem,
Thus, the output for input n consist precisely of the coefficients of the above polynomial.
Code
[:p.2&^;$&_.5 Monadic verb. Argument: n
$&_.5 Yield an array of n instances of -0.5.
2&^ Compute 2^n.
; Link the results to the left and right.
This specifies a polynomial of n roots (all -0.5)
with leading term 2^n.
[:p. Convert from roots to coefficients.
Samau, 8 5 bytes
Saved 3 bytes thanks to Dennis.
▌2\$ⁿ
Hex dump (Samau uses CP737 encoding):
dd 32 2f 24 fc
Explanation:
▌ read a number
2\ push the array [1 2]
$ swap
ⁿ take the convolution power
Convolving two vectors is equivalent to multiplying two polynomials. Similarly, taking the n-th convolution power is equivalent to taking the n-th power of a polynomial.
MATL, 8 bytes
1i:"2:X+
Inspired by @alephalpha's PARI/GP answer.
Try it online! (uses Y+
for modern day MATL)
How it works
1 % Push 1.
i: % Push [1 ... input].
" % Begin for-each loop:
2: % Push [1 2].
X+ % Take the convolution product of the bottom-most stack item and [1 2].