The greatest value that a (signed) 32 bit integer can hold is 2^31-1 (=2,147,483,647).
Try the long long/int64_t type.
Edit: besides, you can abort the search if you found at least one divisor, because then you know the number isn't prime (except for 2).
You also only need to test all numbers up to sqrt(num), because all divisors would have a counterpart (namely the result of the division) on the "other side of the square root".
:/ correct me if I'm wrong but isn't the proof of prime numbers unsolved? AS IN: there is no equation that produces prime numbers infallibly?
You are correct. I also recall a professor of mine saying that if we manage to prove Riemann's hypothesis then we can use this to also find a formula that produces prime numbers, or something like that... I wasn't really paying attention...
But, of course, nobody forbids you to test if a given number is prime by doing a bunch of divisions. It just takes more and more time as the numbers you test grow.