[Solved] how can i work with 16 digit integer type?


The biggest value an int can hold is 2,147,483,647. Change the variables to unsigned long long, which can hold a maximum of over 18,446,744,000,000,000,000. (You’ll need to use %llu to read in/out unsigned long long variables)

Also, always validate inputs, this would have hinted at the issue.

if(scanf("%d", &a) < 1) { //if we read less than one
    printf("FAILED TO READ INPUT");
    return 1;
}

Finally, you’re iterating from 2 to 1000000000000000, which is going to take a LONG time regardless of what’s inside the loop. You’ll need to use a faster algorithm in order to complete in the one second deadline.

4

solved how can i work with 16 digit integer type?