/ Published in: C++
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/*Alexander DeTrano Project Euler - Problem 3 2/5/2011 The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? */ #include <iostream> #include <math.h> using namespace std; int main() { long z=600851475143; cout<<"z="<<z<<endl<<endl; for(int i=2;i<=sqrt(z);i++){ while(z%i==0 && z!= i){ cout<<"Current z="<<z<<endl; cout<<z<<"%"<<i<<"="<<z/i<<endl; z=z/i; cout<<"New z="<<z<<endl<<endl; } } }