Sum of prime numbers in the input in python using def

Solution 1: Sum of n Prime Numbers in Python

n = int[input[]]
list = []
sum = 0
for i in range[2, n+1]:
    for j in range[2, i]:
        if i % j == 0:
           break
    else:
        sum = sum + i
print[sum]

Solution 2: Sum of Prime Numbers in the Input in Python

def sumOfPrimes[n]: 
    prime = [True] * [n + 1] 
      
    p = 2
    while p * p 

Chủ Đề