斐波那契数列

#include <iostream>

#include <cstdio>

using namespace std;

int fib(int n)

{

    if(n==1 || n==2) return 1;

    else return fib(n-1)+fib(n-2);

}

int main()

{

    int n;

    cin>>n;

    cout<<fib(n)%1000;

    return 0;

}

posted @ 2020-08-28 23:27  py佐料  阅读(89)  评论(0编辑  收藏  举报