Today I wrote a program using an array / list with 64,000,000 entries. However, when writing sigma=[1]*64000000using Python, it works fine, but later, as the program computes, my Ubuntu freezes - without any reaction to the input, even the mouse movement. I tried twice and the results remained the same.
When it is implemented in C ++, it long long sigma[64000000]works great and works very fast.
Is there a reason why my program freezes in the middle of launch, except for crashes at the beginning?
EDIT: To answer Chris below, my code did not freeze until a few loops appeared.
Thanks everyone!
For those who are interested in viewing the code, this is a program, project Euler 211 with brute force:
def e211():
ans=0
sigma=[1]*64000000
for i in range(2,64000000):
j=i;
if ((j%1000==0) or (j<100)):
print(j)
q=i*i
while j<64000000:
sigma[j]+=q
j+=i
for i in range(1,64000000):
j=int(sqrt(sigma[i]))
if j*j==sigma[i]:
ans+=i
if __name__=='__main__':
print(e211())