integer constant is too large for type

Hi,

I'm trying to solve the problems at Project Euler (projecteuler.net). I think I've got the algorithm right but I'm restricted by the range of values an unsigned long long can take.

Here's the problem:

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

What is the largest prime factor of the number 317584931803?

Here's my code:

Code:

`#include <iostream>`

using std::cout; using std::cin;

using std::endl;

int main()

{

unsigned long long int num = 317584931803;

unsigned long i;

unsigned long primefactor;

for (i=2; i <= num; i++)

{

if (num % i == 0)

{

while (num % i == 0)

num /= i;

primefactor = i;

}

}

cout << primefactor;

return 0;

}

I even tried finding the smallest prime factor, dividing by it, and using the result. The smallest prime factor is 67. The result of the division is 4740073609, which is still too large for the type. I kept on trying to find another prime factor, but I reached 300 with no others.

Can anyone tip me onto the right track?