| 1 | #!/usr/bin/env python2
 | 
| 2 | from __future__ import print_function
 | 
| 3 | """Recursive version if Fibonacci."""
 | 
| 4 | 
 | 
| 5 | 
 | 
| 6 | def unused():
 | 
| 7 |   """A function that shouldn't be compiled."""
 | 
| 8 |   return 42
 | 
| 9 | 
 | 
| 10 | 
 | 
| 11 | def fib(n):
 | 
| 12 |   if n == 0:
 | 
| 13 |     return 1
 | 
| 14 |   elif n == 1:
 | 
| 15 |     return 1
 | 
| 16 |   else:
 | 
| 17 |     return fib(n-1) + fib(n-2)
 | 
| 18 | 
 | 
| 19 | print(fib(9))
 | 
| 20 | 
 | 
| 21 | 
 | 
| 22 | # TODO: Do this later.
 | 
| 23 | if 0:
 | 
| 24 |   def main():
 | 
| 25 |     for i in xrange(9):
 | 
| 26 |       print(fib(i))
 | 
| 27 |     print('Done fib_recursive.py')
 | 
| 28 | 
 | 
| 29 | 
 | 
| 30 |   if __name__ == '__main__':
 | 
| 31 |     import os
 | 
| 32 |     if os.getenv('CALLGRAPH') == '1':
 | 
| 33 |       import sys
 | 
| 34 |       from opy import callgraph
 | 
| 35 |       callgraph.Walk(main, sys.modules)
 | 
| 36 |     else:
 | 
| 37 |       main()
 |