python实现判断200以内可逆素数(整数颠倒也为素数)

def judge(i):
    for j in range (2,i//2):
        if i%j==0:
            return 0
    return 1
print(2)
for i in range(3,201):
    if i<10 and judge(i)==1 :
            print(i)
    if i>10 and i<100 and judge(i)==1:
        if judge(i%10*10+i//10%10)==1:
            print(i)
    if i>100 and judge(i)==1: 
        if judge(i%10*100+((i//10)%10)*10+((i//10)//10))==1:
            print(i)

你可能感兴趣的:(编程题)