当前位置:网站首页>Find a number between two Fibonacci series
Find a number between two Fibonacci series
2022-07-21 03:27:00 【Aisxi】
def fib_interval(x):
""" returns the largest fibonacci
number smaller than x and the lowest
fibonacci number higher than x"""
old, new = 0, 1
while True:
if new < x:
old, new = new, old+new
else:
if new == x:
new = old + new
return (old, new)
while True:
x = int(input("Your number: "))
if x <= 0:
break
lub, sup = fib_interval(x)
print("Largest Fibonacci Number smaller than x: " + str(lub))
print("Smallest Fibonacci Number larger than x: " + str(sup))
边栏推荐
猜你喜欢
随机推荐
Flink SQL自定义解析 Map和Array数据类型
Flink 分流之 Filter/Split/SideOutPut 比较
antd mobile 表单验证 rc-form 使用
Redis发布与订阅
Redis持久化
<srcipt>标签上的 ‘defer‘和‘async‘ 属性的作用
使用 poi 导入导出
Configuration of Visual Studio development environment
(五)PyTorch深度学习:Logistic回归
达梦免密登录
JDBC 和 ODBC 的区别
Select all on the current page of Ali vector Gallery
Centos8(linux)安装mysql8.0.28
Spark SQL 中的小 TIPS
kettle_配置数据库连接_报错
一致性哈希,虚拟节点,布隆过滤器
(十)PyTorch深度学习:卷积神经网络( 简单的残差卷积神经网络)
达梦DTS工具使用
The role of 'defer' and 'async' attributes on the < srcipt> tag
Hyperledger Fabric 超级账本 CA集群搭建使用