Problem 3 Largest prime factor
https://projecteuler.net/problem=3
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
题意:找出一个合数的最大质数因子
c++
#include<iostream>
using namespace std;
int f(long long x){
long long i=2;
while(x>1){
if(x%i==0){
x/=i;
}else{
i++;
}
}
return i;
}
int main(){
cout<<f(600851475143)<<endl;
return 0;
}
//6857