逢7过游戏
while 循环
i = 1
while i < 100:
if i % 7 == 0 or i % 10 == 7 or i // 10 == 7:
print("过")
else:
print(i)
i += 1
for 循环
for i in range(1,100):
if i % 7 == 0 or i % 10 == 7 or i // 10 == 7:
print('过')
else:
print(i)
打印自幂数
while 循环
i=1
while True:
sum = 0
list = str(i)
long = len(list)
b= 0
while b <long:
sum+=int(list[b])**long
if sum == i:
print(i)
i +=1
for 循环
for i in range(1,100000000000000000000):
sum = 0
list = str(i)
long = len(list)
for b in list:
sum+=int(b)**long
if sum == i:
print(i)
打印质数
while 循环
import math
i = 2
while i < 100000000000:
sqrt = math.sqrt(i)
count = 0
for a in range(2, int(sqrt) + 1):
if (i % a == 0):
continue
count += 1
if count == int(sqrt) - 1:
print(i)
i += 1
for 循环
import math
for i in range(2, 1000):
sqrt = math.sqrt(i)
count = 0
for a in range(2, int(sqrt) + 1):
if (i % a == 0):
continue
count += 1
if count == int(sqrt) - 1:
print(i)
import math