a) post what you actually tried, not a description.
b) post your actual error messages
c) tell us what your OS/Compiler is.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
From this thread I would suggest you to use: <strong>unsigned long long</strong> :)
>can long long store 12 digit numbers.
Depends on what your compiler is...
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
>i don't want to use array.
In that case there's probably no other choice left than choosing for a Big Number library like GNU MP , it can handle much bigger numbers than a standard C++ datatype can...
And take a look at Salem's post as well:What is your compiler?
What is your OS?
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
Try to append LL suffix to long long constants.
ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,234
Solved Threads: 348
Try
long long num=600851475143LL,large,k,i;
to tell the compiler that the constant is a long long.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
>thanks man, a million thanks. It works
So, what is stopping you to mark the thread as Solved.
siddhant3s
Practically a Posting Shark
816 posts since Oct 2007
Reputation Points: 1,486
Solved Threads: 140
> integer constant is too large for ‘long’ type
Oh come on, we've told you how to fix "long long" constants, can't you at least make some intuitive guess as to how to fix "long" ?
And "mark as solved" is a link at one end of the thread (top or bottom, I forget, you can find it).
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
The integers are too big. You will have to explicitly flush the stream as it takes a hell lot of time to generate the next number which makes your condition true.
Also, postfix LL after the long long constants as already told by others.
#include<iostream>
using namespace std;
int main()
{
unsigned long long i;
for (i=999999999LL;i<1234567890123LL;++i)
if (i%100000000==0)
cout<<i<<flush; //check here
}
Read this post for a possible explanation: http://www.daniweb.com/forums/post873624.html#post873624
siddhant3s
Practically a Posting Shark
816 posts since Oct 2007
Reputation Points: 1,486
Solved Threads: 140