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

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 0.36 KB  |  hits: 13  |  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. Same algorithm implementation has different retults in Python and C  ?
  2. def fib(x):
  3.     v = 1
  4.     u = 0
  5.     for x in xrange(1,x+1):
  6.         t = u + v
  7.         u = v
  8.         v = t
  9.     return v
  10.        
  11. int fib(int x)
  12. {
  13.     int v = 1;
  14.     int u = 0;
  15.     int t;
  16.     for (int i = 1; i != x + 1; i++)
  17.     {
  18.         t = u + v;
  19.         u = v;
  20.         v = t;
  21.     }
  22.     return v;
  23. }