Return to Snippet

Revision: 40734
at February 6, 2011 11:10 by mju4t


Initial Code
/*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;
       }
    }
}

Initial URL

                                

Initial Description

                                

Initial Title
Project Euler Problem 3

Initial Tags

                                

Initial Language
C++