请问要怎么用python写函数fun(),它的功能是求Fibonacci数列中小于t的最大的一个数,结果由函数返回。

请问要怎么用python写函数fun(),它的功能是求Fibonacci数列中小于t的最大的一个数,结果由函数返回。其中Fibonacci数列F(n)的定义为
F(0)=0,F(1)=1
F(n)=F(n-1)+F(n-2)
例如:t=1000时,函数值为987。
没有思路,请指导


def fibonacci(index):
  a,b = 0,1
  for value in range(index):
    a,b = b,a+b
  return a

# while 循环查找小于t的最大数
max_num = 0
index = 0
t = 1000
while True:
  value = fibonacci(index)
  if value > t:
    break
  else:
    max_num = value
    index += 1

print(f'小于{t}的最大数:{max_num}')

img

img