slowfib.py 261 B

12345678910111213141516
  1. #!/usr/bin/env python
  2. def fib(x):
  3. if x <= 1:
  4. return x
  5. else:
  6. return fib(x-1) + fib(x-2)
  7. def main():
  8. for x in range(0,30):
  9. print fib(x)
  10. if __name__ == '__main__':
  11. import cProfile
  12. cProfile.run('main()', 'demo.prof')