Pell数列

#include <iostream>

#include <cstdio>

using namespace std;

int fun(int n)

{

    if(n==1) return 1;

    if(n==2) return 2;

    if(n>2) return 2*fun(n-1)+fun(n-2);

}

int main()

{

    int n;

    cin>>n;

    cout<<fun(n)%32767;

    return 0;

}

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