Problem: Find the number of integers 1 < n < 10^7, for which n and n + 1 have the same number of positive divisors. For example, 14 has the positive divisors 1, 2, 7, 14 while 15 has 1, 3, 5, 15.
I can't reach 10^7 because it is too big number for C and me. How can i solve this problem in C?
printf("%d and %d\n",number-1,number);
printf("\nThere is %d integers.",j);
int divisorcount(int num)
long long num = 100000000LL;? C isn't smart enough to conclude the type on the right side from the left
long long so you have to add the
LL. With this approach you should be able to handle larger numbers than normal integers, just change your functions and variables in a suitable way.
long long is always at least
2^64 bit in size which you can check on Wikipedia.
Hint: As someone mentioned in the comments, Project Euler is not about bruteforcing. This is a lame approach. Think about some better strategies. You might want to get help at math.stackexchange?
EDIT: I don't know why I thought, that a
uint32_t is not enough for
10^7 - sorry for that mistake.