Home > other >  Python, a great god for prime Numbers and sum within 1000
Python, a great god for prime Numbers and sum within 1000

Time:11-03

Before the post is a prime, on the basis of the sum

CodePudding user response:

To find prime Numbers saved to a list, the sum is not line?

CodePudding user response:

 

Slist=[]
For the x in the range (1000) :
# judgment if x is a prime number, the print, if not a prime number is skipped
If x & lt; 2:
The continue
For I in range (2 x) :
If I==0 x % :
Break
The else:
Slist. Append (x)
Print (slist)
Print (sum (slist))