浏览代码

Add 'J.py'

webturing 4 年之前
父节点
当前提交
fe95e6ffbd
共有 1 个文件被更改,包括 15 次插入0 次删除
  1. 15 0
      J.py

+ 15 - 0
J.py

@@ -0,0 +1,15 @@
+import math
+ 
+n = int(input())
+a = list(range(n + 1))
+a.remove(0)
+a.remove(1)
+for i in range(2, int(math.sqrt(n)) + 1):
+    if i not in a:
+        continue
+    for j in range(i * i, n + 1, i):
+        if j in a:
+            a.remove(j)
+ 
+for i in a:
+    print(i)