#include <stdio.h>
#include <stdbool.h>

int fib(int n);
bool is_prime(int n);

int main(int argc, char** argv) {

    int fib10 = fib(10);
    bool b = is_prime(fib10);

    printf("%d is prime: %d (0 = false, 1 = true)\n", fib10, b);

    return 0;
}

int fib(int n) {
    // We will keep track of the current and previous Fibonacci number.
    // The first first Fibonacci number is 0 and the next is 1.
    int previous = 0;
    int current  = 1;

    for (int i = 1; i <= n; i++) {
        // Go to the next Fibonacci number
        int current_backup = current;
        current = current + previous;
        previous = current_backup;
    }

    return current;
}

bool is_prime(int n) {
    for (int divisor = 2; divisor < n; divisor++) {
        if (n % divisor == 0) { // divisor divides n
            return false;
        }
    }

    return true;
}
