Euler #3

telat satu hari nih -_-, makanya copas dari situs lain, akibat kejar tayang 😀

https://projecteuler.net/archives

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

What is the largest prime factor of the number 600851475143 ?

#bilangan prima dari 600851475143? hasil dari compile listing dibawah : 2,2,3,164728111.


#include <iostream>
using namespace std;
int prime(int x) {
int a;

for(a=2;a<=x;a++) {
if(x%a==0) {
cout << a << " * ";
x/=a;
a--;
}
}
return 0;
}

main() {
int x;
cin.clear();
cout << "masukan bilangan"<<endl; cin >> x;
prime(x);
system ("pause");
return 0;

}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s