在这段代码中:
#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);
}
Run Code Online (Sandbox Code Playgroud)
编译时:
$ gcc -Wall -g 3.c -o 3 -lm
Run Code Online (Sandbox Code Playgroud)
运行生成的可执行文件时,我得到一个"浮点异常".代码中没有浮点数.这里出了什么问题,我需要做些什么才能解决问题?