[Python 123] The sum of prime numbers within 100

description

Find the sum of all prime numbers within 100 and output. To
It refers to a prime To
Tip: You can individually Determine whether each number within 100 is a prime number, and then sum.

Input format

The question is not entered

Input and output example

enter Output
Example 1 1234 (this is an example, not real output)

Python code

sum = 0
for i in range(2, 101):
    for j in range(2, round(i ** 0.5) + 1):
        if i % j == 0:
            break
    else:
        sum = sum + i
print(sum)

Output result

1060 1060 1060

Guess you like

Origin blog.csdn.net/weixin_43012724/article/details/103425562