In this code:
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
int main (int argc, char ** argv) {
uint64_t bignum = 600851475143;
int is_prime = 0;
uint64_t result = 0;
uint64_t i = 0;
uint64_t j = 0;
for (i = 0; i < bignum; i++) {
if (bignum % i == 0) {
is_prime = 1;
for (j = 0; j < i; j++) {
if (i % j == 0) {
is_prime = 0;
break;
}
}
if (is_prime) {
result = i;
}
}
}
printf("The largest prime factor of the number %lu is %lu.\n", bignum, result);
}
when compiling with:
$ gcc -Wall -g 3.c -o 3 -lm
I get a "floating point exception" upon running the resulting executable. There are no floating point numbers in the code. What is going wrong here, and what do I need to do to resolve the problem?