I'm making an algorithm to factor a fairly large number and it's not working. I know that factoring large numbers isn't a great task for a computer, but the problem I'm working on was designed to be solvable. I think the problem is the range of unsigned long long, but the sizeof function indicates that this type is big enough for my number. My program operates as if my input overflows. Furthermore, as a test, I made a short program to overflow the type and I'm perplexed by the result. Here's the test:
#include <stdio.h>
int main (void)
{
unsigned long long x = 600851475143;
printf ("%d", x);
return 0;
}
The value printed is -443946297. What's going on here?
"%llu"
forlong long unsigned
– Indiana Kernick Sep 14 '18 at 2:40