0

I have a question about my program.

I am getting a compiler error : Segmentation fault

Always, if the computed number is about 19 digits, I am getting the error above.

Do I need another data type or it is just the huge number ?

Code below :

// calculates Fibonacci numbers

int main(void) {
    unsigned long long fibo[4000000] = {[0] = 0, [1] = 1}, i, j;
    for ( i = 2; i < 4000000; i++) {
        fibo[i] = fibo[i-1] + fibo[i-2];
    }
    for ( j = 0; j < 4000000; j++) {
        printf("%llu, ", fibo[j]);
    }
    printf("\n");
    return 0;
}
Weather Vane
  • 33,872
  • 7
  • 36
  • 56

0 Answers0