3744 - ELHC: Difference between revisions
Pagină nouă: def prim(n): cnt = 0 for i in range(1, int(n) + 1): if n % i == 0: cnt += 2 if i * i == n: cnt -= 1 if cnt == 2: return 1 else: return 0 if __name__ == '__main__': n = int(input()) for i in range(2, n + 1): if prim(i): print(i, end=' ') |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
def prim(n): | def prim(int n): | ||
cnt = 0 | cnt = 0 | ||
for i in range(1, int(n) + 1): | for i in range(1, int(n) + 1): | ||
Line 10: | Line 10: | ||
else: | else: | ||
return 0 | return 0 | ||
if __name__ == '__main__': | if __name__ == '__main__': |
Latest revision as of 15:11, 4 December 2023
def prim(int n):
cnt = 0 for i in range(1, int(n) + 1): if n % i == 0: cnt += 2 if i * i == n: cnt -= 1 if cnt == 2: return 1 else: return 0
if __name__ == '__main__':
n = int(input()) for i in range(2, n + 1): if prim(i): print(i, end=' ')