projecteuler_problem3

problem3

地址:https://projecteuler.net/problem=3
源码:git@code.aliyun.com:qianlizhixing12/ProjectEuler.git。
问题:找到600851475143最大质因数。

#include <stdio.h>

#define MAXNUM 600851475143

int main(int argc, char **argv){
    long long int tmp = MAXNUM;
    long long int i;

    i = 2;
    while (i <= tmp){
        while (! (tmp % i)){
            tmp = tmp / i;
        }
        if (1 == tmp) break;
        i++;
    }

    printf("Problem3  Answer: %lld\n", i);

    return 0;
}
时间: 2024-07-30 17:31:30

projecteuler_problem3的相关文章