浙大Python 第4章-6 输出前 n 个Fibonacci数 (15 分)

原题题目

在这里插入图片描述



代码实现

number = int(input());pre = now = temp = 1;count = 0
if(number<1):print("Invalid.")
else:
    while count<number:
        if count == 0 : print("%11d" %pre,end = '')
        else: print("%11d" %now,end = '');temp = pre;pre = now;now += temp
        count+=1;
        if (count % 5 == 0 or (count == number)): print(end = '\n')


提交结果

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_37500516/article/details/114378939
今日推荐