Memory limit exceeded / exit status -1 ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Memory limit exceeded / exit status -1 ?

I'm currently trying to create a HCF and LCM calculator for any two given numbers, and, when finding the prime factors as a number, i'm trying to return them as a list. however, when i store the returned list into a variable or try to output the contents via iteration, i'm greeted with a "exit status -1" on the compiler or "memory limit exceeded" on solo learn. i I've read that returning lists or vectors can be quite expensive, could that perhaps be it? and also, what does "exit status -1" mean in general? original code: additional info on the program will be commented in the project.

3rd Jul 2018, 4:36 PM
X-1 - avatar
1 Answer
+ 2
In your while-loop on line 35, your condition is if num is a prime or not, but you never actually change num so it never becomes a prime number => infinite loop. I think you just forgot a "num /= index;" after pushing the index into the list. "exit-status -1" is a general error message, indicating your program was shut down because of an unsuccessful termination status.
3rd Jul 2018, 4:49 PM
Shadow - avatar