Skip to content

Instantly share code, notes, and snippets.

@gsauthof
Created July 25, 2016 06:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsauthof/251384a05cf6608d27545ed199d46e80 to your computer and use it in GitHub Desktop.
Save gsauthof/251384a05cf6608d27545ed199d46e80 to your computer and use it in GitHub Desktop.
Syntactic variation of a Fibonacci example
// in reply to http://verse.systems/blog/post/2016-07-18-Software-Engineering-Teaching/
unsigned fibonacci(unsigned n) {
unsigned a = 0, b = 1;
unsigned sum = 0;
for ( ; n > 0; --n) {
unsigned t = b;
b += a;
a = t;
sum += a;
}
return sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment