#include<bits/stdc++.h> using namespace std; int main() { int n; long long a[100]; while(scanf("%lld",&n)!=EOF&&n!=0) { a[1]=1,a[2]=2; for(int i=3;i<=n;i++) { a[i]=a[i-1]+a[i-2]; } printf("%lld\n",a[n]); } return 0; } |
Double click to view unformatted code.