View Code of Problem 23

#include<stdio.h>
void main(){
  int M;
  while(scanf("%d",&M)!=EOF){
    if(M==0) break;
    long long num[M];
    num[0]=1;num[1]=2;
    for(int i=2;i<M;i++)
      num[i]=num[i-1]+num[i-2];
    printf("%lld\n",num[M-1]);
  }
}

Double click to view unformatted code.


Back to problem 23