Skip to content

Instantly share code, notes, and snippets.

@hansen033
Created November 2, 2017 12:11
Show Gist options
  • Save hansen033/c8e8e1d8b5fd13c1ca331f7d2431737b to your computer and use it in GitHub Desktop.
Save hansen033/c8e8e1d8b5fd13c1ca331f7d2431737b to your computer and use it in GitHub Desktop.
2017/11/02 上課測驗
#include <iostream>
using namespace std;
int main()
{
int first, second, max;
cout << "請輸入你要小於等於多少數值得費氏數列:\n";
cin >> max;
first = 1;
second = 1;
cout << "1 ";
while (true){
if (second<=max){
cout << second << " ";
second = second + first;
first = second - first;
} else {
break;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment