Your literal as typed has type int
which isn't big enough to hold the value. Try 600851475143ULL
as a first fix.
Note even with that, your for
loop will never terminate since an unsigned can never be less than 0. Instead, use a long long
and 600851475143LL
.