joseleonweb

Untitled

Feb 4th, 2021
765
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.33 KB | None | 0 0
  1. static ulong fibonacciIteratiu(ulong n)
  2. {
  3.     ulong n1, n2, i, aux;
  4.     if (n == 0 || n == 1) return n;
  5.     else
  6.     {
  7.         n1 = 0;
  8.         n2 = 1;
  9.         i = 1;
  10.         while (i < n)
  11.         {
  12.             aux = n2;
  13.             n2 = n2 + n1;
  14.             n1 = aux;
  15.             i++;
  16.         }
  17.         return n2;
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment