/*Largest prime factor
Problem 3 The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?*/
using namespace std;
int main() { long long num=600851475143 ,largest=1 ; for(int i=2;i<=num;i++) { if(num%i==0) { num=num/i; cout< if(i>largest) largest=i; }
} cout<<"\n\n"<<"the largest prime factor of the number 600851475143 is "<<largest<<"\n"; return 0; }
My code in C++ >>Output>>6857
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
/*Largest prime factor
Problem 3
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?*/
include
using namespace std;
int main()
{
long long num=600851475143 ,largest=1 ;
for(int i=2;i<=num;i++)
{
if(num%i==0)
{
num=num/i;
cout< if(i>largest)
largest=i;
}
}
cout<<"\n\n"<<"the largest prime factor of the number 600851475143 is "<<largest<<"\n";
return 0;
}
My code in C++ >>Output>>6857