void fib(int** array, int n) {
    *array = malloc(sizeof(int) * n);
    int term1 = 0;
    int term2 = 1;
    int next;
    if (n == 1) {
        (*array)[0] = term1;
    } else if (n == 2) {
        (*array)[0] = term1;
        (*array)[1] = term2;
    } else {
        (*array)[0] = term1;
        (*array)[1] = term2;
        for (int i = 2; i < n; i++) {
            next = term1 + term2;
            (*array[i]) = next;
            term1 = term2;
            term2 = next;
        }
    }
}


int main(int argc, char **argv) {
    /* do not change this main function */
    int count = strtol(argv[1], NULL, 10);
    int *fib_sequence;

    fib(&fib_sequence, count);
    for (int i = 0; i < count; i++) {
        printf("%d ", fib_sequence[i]);
    }
    free(fib_sequence);
    return 0;
}
store up to n fibonacci numbers in a dynamically allocated array and print each element