0

Ques:

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

What is the largest prime factor of the number 600851475143 ?

I came up with the following code. This did compile in VC++ Express Edition without any errors/warnings. But i only get a blank output screen. Someone plz point out where i went wrong?

```
#include <iostream>
#include <vector>
using namespace std;
class factor
{
public:
/*_int64*/ long long target;
vector<long long> pno;
vector<long long> ::iterator it;
void prime();
};
void factor::prime()
{
target = 600851475143;
int flag = 0;
pno.push_back(2);
pno.push_back(3);
pno.push_back(5);
pno.push_back(7); // Pushing prime no s within 10 into the vector
for (long long i = 11; i<target; i++)
{
if(i%2||i%3||i%5||i%7)
continue;
else
pno.push_back(i); // Checking if the no has factors other than itself and 1, then pushing it into the vector.
}
cout << "Prime No" << endl << endl;
for (it = pno.begin(); it != pno.end(); it++)
{
cout << *it << "\t";
}
cout << endl << endl; // Printing the vector for reference
for (int j = (pno.size()-1); j>0; j--)
{
if(target%(pno[j]))
{
cout << "Largest prime factor of the no '600851475143' : " << pno[j] << endl << endl;
break;
}
} // Checking the vector of prime no s if it a factor of the target no. Since we are traversing the vector back to front, the first factor we find is the largest prime factor of the target no.
}
int main()
{
factor inst;
inst.prime();
}
```