tim_ryspekov

Ryspekov's Fibonacci sequence formula PYTHON

Jun 12th, 2017
851
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. def zn(x):
  2.     x=abs(x)
  3.     x+=4
  4.     x=x//5
  5.     x=pow(2,x)%2
  6.     return x
  7.  
  8. b=int(input());
  9. b=b-1
  10. x=1
  11. n=2
  12. while(n<b):
  13.     n=n+1
  14.     k=int(x*(1+pow(5,0.5))/2);
  15.     x=k+zn(n%3)*(k%2)+(1-zn(n%3))*zn(k%2);
  16.     print(x);
  17. else:
  18.  print()  
  19. n=n+1
  20. x=x-zn(b)
  21. print(x)
Add Comment
Please, Sign In to add comment