Cod sursa(job #2165717)

Utilizator 24601Dan Ban 24601 Data 13 martie 2018 13:18:14
Problema Al k-lea termen Fibonacci Scor 100
Compilator c Status done
Runda Arhiva educationala Marime 0.33 kb
#include <stdio.h>

#define MOD 666013
#define PER 1332028

int main(void) {

    long k, x = 0, y = 1, z;

    freopen("kfib.in", "r", stdin);
    freopen("kfib.out", "w", stdout);

    scanf("%ld", &k);

    while(k-- % PER) {
        z = (x + y) % MOD;
        x = y;
        y = z;
    }

    printf("%ld\n", x);

    return 0;
}