Skip to content

Instantly share code, notes, and snippets.

@nealg223
Created December 3, 2012 19:19
Show Gist options
  • Save nealg223/4197252 to your computer and use it in GitHub Desktop.
Save nealg223/4197252 to your computer and use it in GitHub Desktop.
#include <stdio.h>
unsigned int fib(unsigned int n) {
unsigned int a = 1, b = 1;
unsigned int tmp;
while (--n >= 0) {
tmp = a;
a += b;
b = tmp;
}
return a;
}
main() {
printf("%u", fib(10));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment