2024/4/7

所花时间:1小时

代码行:70行

博客量:1篇

了解到的知识点

def fib(n):
if n == 0 or n == 1:
return 1
a, b = 1, 1
for _ in range(2, n+1):
a, b = b, a + b
return b

def PrintFN(m, n):
fib_list = []
a, b = 1, 1
while b <= n:
if b >= m:
fib_list.append(b)
a, b = b, a + b
return fib_list

 

def isPrime(n):
if n <= 1:
return False
for i in range(2, int(n**0.5)+1):
if n % i == 0:
return False
return True

def primeSum(x, y):
prime_sum = 0
for num in range(x, y+1):
if isPrime(num):
prime_sum += num
return prime_sum

posted @ 2024-04-07 21:19  为20岁努力  阅读(6)  评论(0编辑  收藏  举报