Skip to content

Instantly share code, notes, and snippets.

@aoirint
Created July 20, 2017 12:42
Show Gist options
  • Save aoirint/cac1acf5c7b47afb64b513a5ee09c4b9 to your computer and use it in GitHub Desktop.
Save aoirint/cac1acf5c7b47afb64b513a5ee09c4b9 to your computer and use it in GitHub Desktop.
C++でフィボナッチ数列のテスト
#include<iostream>
int fibo(int i) {
if (i == 1) return 0;
if (i == 2) return 1;
return fibo(i-1) + fibo(i-2);
}
// int main(int argc, char *argv[]) {
int main() {
for (int i=1; i<31; i++) {
std::cout << fibo(i) << "\n";
}
std::cout << std::flush; // まとめてフラッシュ
/*
for (int i=1; i<31; i++) {
std::cout << fibo(i) << std::endl;
}
*/
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment