首页 > 其他 > 详细

1001 害死人不偿命的(3n+1)猜想

时间:2018-12-17 20:04:51      阅读:117      评论:0      收藏:0      [点我收藏+]

https://pintia.cn/problem-sets/994805260223102976/problems/994805325918486528

 

n=int(input("please input the number:"))
i=0
while n!=1:
  if n%2==0:
    n=n/2
  else:
    n=(3*n+1)/2
  i+=1
print(i)

 

反思:1python3 没有raw_input了,都是input,注意输入的是默认string类型,可以用int ,float 进行格式变化

          2,input里放置面可以放置要输出的内容

1001 害死人不偿命的(3n+1)猜想

原文:https://www.cnblogs.com/captain-dl/p/10133087.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!