Skip to content

Instantly share code, notes, and snippets.

@santinoyanz
Created Jun 20, 2020
Embed
What would you like to do?
Fibonacci Number
int fibo(int);
int fibo(int N) {
if (0 == N) return 0;
if (1 == N || 2 == N) return 1;
int pre = 1, cur = 1;
for (int i = 3; i <= N; ++i) {
int sum = pre + cur;
pre = cur;
cur = sum;
}
return cur;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment