Created
January 4, 2014 00:37
-
-
Save mikedugan/8249709 to your computer and use it in GitHub Desktop.
iterative C# implementation of a Fibonacci sequence
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static int Fibonacci(int n) | |
| { | |
| int a = 0; | |
| int b = 1; | |
| // In N steps compute Fibonacci sequence iteratively. | |
| for (int i = 0; i < n; i++) | |
| { | |
| int temp = a; | |
| a = b; | |
| b = temp + b; | |
| } | |
| return a; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment