(Problem 3)Largest prime factor

The prime factors of 13195 are 5, 7, 13 and 29.

What is the largest prime factor of the number 600851475143 ?

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#include<stdlib.h>
#include<stdbool.h> #define N 600851475143 bool prim(int n)
{
int i;
for(i=; i*i<=n; i++)
{
if(n%i==)
return false;
}
return true;
} int main()
{
long long s=sqrt(N);
while(s--)
{
if(s%!= && prim(s) && (N%s==))
{ printf("%lld\n",s);
break;
}
}
return ;
}
Answer:
6857
上一篇:Android开发——构建自定义组件


下一篇:[FreeBuff]*.Miner.gbq挖矿病毒分析报告