So i am trying to generate primes less than 2000000 and find their sum.. For a sample size I tried primes to 40000, but got a Segmentation Fault. I tried many values and I find the number 35044 to be the crashing point of the program.
import sys
sys.setrecursionlimit(100000000)
def stuff(total, rnge):
for n in rnge:
ubound=int(n**0.5)+1
print ubound
for x in range(3, ubound, 2):
if n % x == 0:
stuff(total, range(n+2, 35044, 2))
#print n
total = total + n
#print total
print total
exit()
stuff(17, range(11, 35044, 2))
This is the error that results: "Run Command: line 1: 2942 Segmentation fault: 11 python "$1" "${@:3}"
Side note: Finder also says python crashed and gives me a crash report, including these two bits of interesting info:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00007fff5f3fffb8
Not sure if this is useful.
Also, for those who are wondering, I am on the latest 15-inch rMPB with 16 GB RAM and 2.7 Ghz processor, when I run the program eat eats up all 14GB or something of free RAM then crashes after it prints the number 181 a few times.