Cod sursa(job #2487048)

Utilizator matthriscuMatt . matthriscu Data 3 noiembrie 2019 20:19:49
Problema Al k-lea termen Fibonacci Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.34 kb
#include <iostream>
#include <fstream>
using namespace std;

ifstream fin("kfib.in");
ofstream fout("kfib.out");

int main() {
    int n;
    fin >> n;
    unsigned long long memo[n];
    memo[1] = 1;
    memo[2] = 1;
    for(int i = 3; i <= n; i++){
        memo[i] = memo[i-1] + memo[i-2];
        cout << memo[i] << endl;}
}