python 斐波那契数列,查找素数,水仙花数字

def fbi(n):
    '''斐波那契数列'''
    if n<=2:
        return 1
    else:
        return  fbi(n-1) + fbi(n-2)
# print fbi(8)

def find_prime(start_num, end_num):
    '''找出start_num,与end_num之间的素数'''
    def check_if_prime(num):
        for i in range(2, num):
            if num%i == 0:
                return False
        return True
    for range_num in range(start_num, end_num):
        if check_if_prime(range_num):
            print range_num
# find_prime(100, 150)
def flower_num():
    '''水仙花数字'''
    for num in range(100, 999):
        # print num/100,num/10%10,num%10
        k = num/100
        l = num/10%10
        m = num%10
        if k**3+l**3+m**3 == num:
            print num
# flower_num()

你可能感兴趣的:(python)