2.20 break语句
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
# 统计第1个9在2的100次方中出现的位置:
num = 2**100
pos = 0
for digit in str(num):
pos = pos + 1
if digit == "9":
break
print("2**100 is: %d \nthe first posion of 9 is Pos.%d" %(num,pos))#求2到100之间的素数
i = 2
while(i < 100):
flag = 0
j = 2
while(j <= (i/j)):
if i%j==0:
flag = 1
break
j = j + 1
if (flag == 0) :
print (i, " 是素数")
i = i + 1