Print Floyd's Triangle in Python
Print Floyd's triangle (consecutive numbers in a right-angled triangle).
BeginnerLoop ProgramsExample 24 of 25
print-floyd-s-triangle.py
Run in browser1# Program to print Floyd's triangle23rows = int(input("Enter number of rows: "))45num = 16for i in range(1, rows + 1):7 for j in range(i):8 print(num, end=" ")9 num += 110 print()
Output
Enter number of rows: 4 1 2 3 4 5 6 7 8 9 10
What's going on
We keep a running counter and print increasing numbers row by row.