Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 20th, 2012  |  syntax: None  |  size: 0.47 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import time
  2.  
  3. def worthlessCalculator(n):
  4.         if n <= 3:
  5.                 return 5
  6.  
  7.         output = (3 * worthlessCalculator(n-1) + 5 * worthlessCalculator(n-3) + 7 * worthlessCalculator(n-4) + 11) % 15490549
  8.         return output
  9.  
  10. input = -1
  11. while input < 0:
  12.         input = int(raw_input("Please enter a value >= 0. "))
  13.  
  14. start = time.time()
  15. print("f(" + str(input) + ") = " + str(worthlessCalculator(input)))
  16. executiontime = (time.time() - start) * 1000
  17. print "Elapsed Time:", (time.time() - start) * 1000, "millisecs"