HaniiPuppy

getFib

May 6th, 2016
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.15 KB | None | 0 0
  1. int getFib(int fibIndex)
  2. {
  3.     for(int a = 0, b = 1, i = 1; ; i++)
  4.     {
  5.         if(i == fibIndex) return b;
  6.         b += a;
  7.         a = b - a;
  8.     }
  9. }
Advertisement
Add Comment
Please, Sign In to add comment