0

Hi All,

First time asking so go easy :-)

I am doing c++ a few weeks now, i am doing questions in Project Euler to hopefully improve my coding, But as you will prob see below i am still very new and "Nieve"...

Question is: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143?

My Issue: I am trying to get 5 as the first prime number by putting this in (if((digit > 5) && (digit%5) !=0)) but its not working, can anyone assist or am i maybe writing this whole code the wrong way as in should i use different methode/ loops etc?

Below is my code so far:

```
#include <iostream>
using namespace std;
void main(){
long long int number = 600851475143;
long long int biggestPrime = 1;
for(long long int digit = 1; digit<=number; ++digit){
if((digit%2) !=0 && (digit%3) !=0){
if((digit > 5) && (digit%5) !=0){
if((number%digit) == 0){
if(digit > biggestPrime){
biggestPrime = digit;
cout << digit << endl;
}
}
}
}
}
cout << "Finished";
int dummy; cin >> dummy;
}
```

Any assistance would be greatly appreciated.....

*Edited
by Narue*: n/a