Leaderboard
Showing:
Handle Score
@Ibrahim Nash 6420
@blackshadows 6380
@mb1973 5704
@Quandray 5245
@akhayrutdinov 5111
@saiujwal13083 5046
@sanjay05 3762
@kirtidee18 3673
@mantu_singh 3530
@marius_valentin_dragoi 3523
@sushant_a 3459
Complete Leaderboard
Floyd's triangle
School Accuracy: 69.46% Submissions: 1136 Points: 0

Given a number N. The task is to print Floyd's triangle with N lines.

Example 1:

Input:
N = 4

Output:
1
2 3
4 5 6
7 8 9 10

Explanation:
For N = 4 there are 4 rows in the output
and the number of elements increases 
with an increase in the row.

 

Example 1:

Input:
N = 5

Output:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15

Explanation:
For N = 5 there are 5 rows in the output
and the number of elements increases 
with an increase in the row.

Your Task:  
You don't need to read input. Your task is to complete the function printFloydTriangle() which takes an integer N as input parameter and prints the triangle.

Expected Time Complexity: O(N^2)
Expected Auxiliary Space: O(1)

Constraints:
1 <= N <= 100

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Floyd's triangle

Output Window