Submission

Status:
PPPPP-----

Score: 50

User: www._.

Problemset: อนุกรม

Language: cpp

Time: 0.002 second

Submitted On: 2024-11-03 09:35:35

#include <iostream>
using namespace std; 

int main() {
	long long n;
    cin >> n;
    if (n==1 || n==2) 
    {
    	cout << 1 << endl;
        return 0;
    }

    int n1 = 1, n2 = 1, nextn;
    
    for(int i = 3; i <= n ; i++) 
    {
        nextn = n1+n2 ;
        n1 = n2;
        n2 = nextn;
    }
    
    cout<<nextn<<endl;

    
}