#python
def IsPrime(n):
_divider = 2
while _divider**2 <= n and n % _divider != 0:
_divider += 1
return _divider**2 > n
_sum, i, _counter = 0, 1, 0
N = int(input("N="))
while _counter < N:
if IsPrime(i):
_sum += i
_counter += 1
i += 1
print(f"SUM =", _sum)
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#python
def IsPrime(n):
_divider = 2
while _divider**2 <= n and n % _divider != 0:
_divider += 1
return _divider**2 > n
_sum, i, _counter = 0, 1, 0
N = int(input("N="))
while _counter < N:
if IsPrime(i):
_sum += i
_counter += 1
i += 1
print(f"SUM =", _sum)