Created
July 25, 2016 06:57
-
-
Save gsauthof/251384a05cf6608d27545ed199d46e80 to your computer and use it in GitHub Desktop.
Syntactic variation of a Fibonacci example
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
// 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