fork(5) download
  1. f=lambda n:[0][n:]or[i+j*2for i in 0,1for j in f(n-1)]
  2.  
  3. for n in range(4):
  4. print '%d -> %s' % (n,f(n))
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
0 -> [0]
1 -> [0, 1]
2 -> [0, 2, 1, 3]
3 -> [0, 4, 2, 6, 1, 5, 3, 7]