//非递归求斐波那契数列
#include<iostream>
using namespace std;
long f(int index){
if( index==1 || index == 2){
return 1;
}
long f1 = 1L;
long f2 = 1L;
long f = 0;
for( int i = 0;i < index-2;i ++){
f = f1+f2;
f1 = f2;
f2 = f;
}
return f;
}
int main(){
cout << f(40) << endl;
system("pause");
}