鱼C论坛

 找回密码
 立即注册
查看: 7770|回复: 47

[技术交流] Python:每日一题 207

[复制链接]
发表于 2018-10-10 16:16:53 | 显示全部楼层
def fib(n):
    a=1
    b=1
    if n == 1:
        return 1
    elif n==2:
        return 1
    else:
        for i in range(2,n):
            c=a
            a=b
            b=c+b
        return b
   
def judge(x):
    set1=set()
    l=len(str(x))
    for i in range(0,l):
        set1.add(x//(10**(l-1)))
        set1.add(x%(10**i)//(10**(i-1)))
        set1.add(x%10)
    set1.discard(0)
    list1=list(set1)
    for each in list1:
        if x%each == 0:
            pass
        else:
            return 0
    return 1

   
i=7   
count=0
while 1:
    if judge(fib(i)):
        count+=1
        print(fib(i))
    i+=1
    if count==10:
        break
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-9-26 04:34

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表