Hey there folks. New at this so forgive any mistakes, first post.

I'm beginning to learn c++. Not so easy.
After reading a few threads went to project euler.
Problem i have is problem 3.

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

What is the largest prime factor of the number 600851475143 ?
"

Wrote my program and seems to work on the example given(13195) and on larger numbers,
but when i try anything larger than 10 digits nothing happens and program ends.
Does anyone have any suggestions on how to fix this.
Grateful for any help.
Not posted code didn't think it mattered but can if need be.

Well you're dealing with integer Ranges.
Apart from that for a specific purpose you can apply the size modifiers (long/unsigned) & even use __int64.

Ok, but isn't an unsigned long int only up to 4294967295?
Have to use int i think because am using modulus(%) operator.
As for _int64, have never seen before, could you explain what it is?

Remember am still at very early stage.
Thanks for any help.

>>but isn't an unsigned long int only up to 4294967295?
Yes.

>>As for _int64, have never seen before, could you explain what it is?
A __int64 can also be stated as signed long long, so you can try unsigned long long (0 to 18,446,744,073,709,551,615) this is the largest one I know of. Else you'll have to look up some external library like Java's Bignum.

That seemed to work(long long).
Program was taking forever and never finished but think that was just my bad programming. Gave first 4 prime factors and apparently fouth was biggest.

Thanks for the help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.