使用 for 循环编写一个 Python 程序,以打印斐波那契数列数字模式的直角三角形。
rows = int(input("Enter Right Triangle of Fibonacci Numbers Rows = "))
print("====Right Angled Triangle of Fibonacci Series Numbers Pattern====")
for i in range(1, rows + 1):
First_Value = 0
Second_Value = 1
for j in range(1, i + 1):
Next = First_Value + Second_Value
print(Next, end = ' ')
First_Value = Second_Value
Second_Value = Next
print()

这个 Python 程序使用 while 循环打印斐波那契数列模式数字的直角三角形。
rows = int(input("Enter Right Triangle of Fibonacci Numbers Rows = "))
print("===Right Angled Triangle of Fibonacci Series Numbers Pattern====")
i = 1
while(i <= rows):
First_Value = 0
Second_Value = 1
j = 1
while(j <= i):
Next = First_Value + Second_Value
print(Next, end = ' ')
First_Value = Second_Value
Second_Value = Next
j = j + 1
print()
i = i + 1
Enter Right Triangle of Fibonacci Numbers Rows = 12
===Right Angled Triangle of Fibonacci Series Numbers Pattern====
1
1 2
1 2 3
1 2 3 5
1 2 3 5 8
1 2 3 5 8 13
1 2 3 5 8 13 21
1 2 3 5 8 13 21 34
1 2 3 5 8 13 21 34 55
1 2 3 5 8 13 21 34 55 89
1 2 3 5 8 13 21 34 55 89 144
1 2 3 5 8 13 21 34 55 89 144 233