Skip to main content
1 of 2
Logic Knight
  • 6.8k
  • 1
  • 18
  • 50

Python 2, 56 bytes

I suspect this could be golfed more.

f=lambda n,i=0:[i,f(n,i+1)]if i<n-1 else[i]if n>0 else[]

Tests:

# for n in (0,1,2,6,26,69): print n, '=>', f(n)
0 => []
1 => [0]
2 => [0, [1]]
6 => [0, [1, [2, [3, [4, [5]]]]]]
26 => [0, [1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12, [13, [14, [15, [16, [17, [18, [19, [20, [21, [22, [23, [24, [25]]]]]]]]]]]]]]]]]]]]]]]]]]
69 => [0, [1, [2, [3, [4, [5, [6, [7, [8, [9, [10, [11, [12, [13, [14, [15, [16, [17, [18, [19, [20, [21, [22, [23, [24, [25, [26, [27, [28, [29, [30, [31, [32, [33, [34, [35, [36, [37, [38, [39, [40, [41, [42, [43, [44, [45, [46, [47, [48, [49, [50, [51, [52, [53, [54, [55, [56, [57, [58, [59, [60, [61, [62, [63, [64, [65, [66, [67, [68]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
Logic Knight
  • 6.8k
  • 1
  • 18
  • 50