Ok, it's a pretty dumb title but represents well what I need to know. I'm pretty much a noob in programming and I found a problem about finding the first 3 perfect numbers. I got it solved, but I wanted to see how far I could go. My computer can compute the first 5 without problem, but the sixht I never reach, since the memory overflows.

Is there a way to give more space to my variables, in order to compute that number? If no, Is there an alternative?

Thnaks in advance for your answers :)

Depends on how you declared the variables. If you used int then you can get twice as much space by declaring either long long or __int64 (compiler dependent). Microsoft compilers recognize long long data type but it is the same size as a long.

Another way is to use a 3d party large number library. There are libraries that let you have an (almost) infinitely large mumber. Or you could, if you have enough experience, write your own large number library.

I alerady declared it unsigned long long, but it wasn't enough haha. I dind't knew about that libraries though, thanks for the advice, I'm checking it out.

You are running out of stack space most likely. Are you running this on Windows, or on Linux?

On Windows. Sorry for taking so long to answer, I was busy.

You are running out of stack space most likely.

Lack of stack space won't cause integer overflow problems.

If you want to work with larger int's, move to a 64 bit system and compiler:

18,446,744,073,709,551,615 is the max integer (unsigned long long int)

Or use an array, and treat it like every element of the array, is a digit in a BIG integer. It is challenging, but not as hard to do as you might think at first.