fork download
  1. def f(n):
  2. a=[0];i=1
  3. while n:a+=[i-a[a[a[i-1]]]];i+=1;n-=1
  4. return a[i-1]
  5.  
  6. for i in list(range(21))+[10000]:
  7. print(i,f(i))
Success #stdin #stdout 0.04s 9984KB
stdin
Standard input is empty
stdout
0 0
1 1
2 1
3 2
4 3
5 4
6 4
7 5
8 5
9 6
10 7
11 7
12 8
13 9
14 10
15 10
16 11
17 12
18 13
19 13
20 14
10000 6823