# Project Euler: Problem # 3 solution in C++

/** `(From:http://projecteuler.net/index.php?section=problems&id=3)`

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

What is the largest prime factor of the number 600851475143 ? */

#include <iostream>

using namespace std;

int main ()

{

long long factorOf = (600851475143);

int num = 2;

while ((num * num) <= factorOf)

if (factorOf % num == 0)

{

cout << num << endl;

factorOf /= num;

}else

num++;

cout << “factor of 600851475143 is: ” << factorOf << endl;

}

Posted on March 25, 2013, in Algorithms, C++, Programming, Project Euler and tagged Project Euler solution in C++. Bookmark the permalink. 3 Comments.

Pingback: Project Euler Problem #2 Solution in Java | Khuram Ali

Pingback: Project Euler Problem# 5 solution in C++ | Khuram Ali

Pingback: Project Euler Problem# 6 solution in C++ | Khuram Ali