第006此课后作业
这个flog=0是不是多此一举啊x = 7
i = 1
flag = 0
while i <= 100:
if (x%2 == 1) and (x%3 == 2) and (x%5 == 4) and (x%6==5):
flag = 1
else:
x = 7 * (i+1) # 根据题意,x一定是7的整数倍,所以每次乘以7
i += 1
if flag == 1:
print('阶梯数是:', x)
else:
print('在程序限定的范围内找不到答案!') 确实,小甲鱼或许是为了各位方便理解?
你这样写也行
x = 7
i = 1
flag = 0
while i <= 100:
if (x%2 == 1) and (x%3 == 2) and (x%5 == 4) and (x%6==5):
print('阶梯数是:', x)
break
else:
x = 7 * (i+1) # 根据题意,x一定是7的整数倍,所以每次乘以7
i += 1
else:
print('在程序限定的范围内找不到答案!')
页:
[1]