Source Code for Me (s-c.me)

Allows you to paste souce code to blogs! Adapted for Twitter! Here is Search Form in case you missed your code.
Tags: Python,fib1,fib2,join1,join2, Created At: 10/24/2016 8:27:00 PMViews:

HTML view:
Copy Source | Copy HTML
  1. #!/usr/bin/env python3
  2. from functools import lru_cache
  3.  
  4. def fib1(n):
  5.     if n < 2:
  6.         return n
  7.     return fib1(n-1) + fib1(n-2)
  8.  
  9. @lru_cache(maxsize=None)
  10. def fib2(n):
  11.     if n < 2:
  12.         return n
  13.     return fib1(n-1) + fib1(n-2)
  14.  
  15. r = list(range(1000))
  16. fout = open('/dev/null', 'w')
  17.  
  18. def join1(r = r, fout = fout):
  19.     print (' '.join(map(str, r)), file = fout)
  20.  
  21. def join2(r = r, fout = fout):
  22.     print (*r, file = fout)
  23.  

Based on Manoli.Net's CodeFormatter. Made by Topbot (c) 2008-2018