Answer the question
In order to leave comments, you need to log in
Why doesn't a C program handle numbers greater than 1999999996?
I wrote a program that increases the power of 10 until a condition breaks the loop.
my code:
int n = 0;
while (1) {
long long int i = 2 * pow(10, n) - 4;
if (i % 19 == 0)
{
printf("%d", n);
break;
}
printf("\t %d\n", i);
n++;
}
Answer the question
In order to leave comments, you need to log in
Because in the formula you have all values of type int, respectively, and the calculations go to int, not long.
long long n10 = 10;
while (1) {
if ((n10 * 2 - 4) % 19 == 0) {
printf("%ld", (n10 * 2 - 4) / 19 * 10 + 2);
break;
}
n10 *= 10;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question