672
支付宝
projecteuler_problem5
problem5
地址:https://projecteuler.net/problem=5。
源码:git@code.aliyun.com:qianlizhixing12/ProjectEuler.git。
问题:找到能整除1到20最小的数。
#include <stdio.h>
#include <math.h>
#include "debug.h"
#include "prime.h"
#define NUM 20
int main(int argc, char **argv){
ptrPrimeNode tmpPtrPrimeNode;
int i;
long int lResult = 1;
debugTime();
initGlobalPrime();
if (NUM > globalPrimeNum)
isPrime(NUM);
tmpPtrPrimeNode = globalPrimeHead;
while ((NULL != tmpPtrPrimeNode) && (NUM <= globalPrimeNum)){
i = 1;
while (pow(tmpPtrPrimeNode->data, i) < NUM)
i++;
lResult *= pow(tmpPtrPrimeNode->data, i - 1);
tmpPtrPrimeNode = tmpPtrPrimeNode->next;
}
printf("Problem5 Answer: %ld\n", lResult);
freeGlobalPrime();
debugTime();
return 0;
}
最后更新:2017-10-02 21:07:46