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

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def printFloydTriangle(self, N):

    	#code here 

Solutions:
class Solution:

	def printFloydTriangle(self, N):
		c = 1
		for i in range(1, N + 1):
			for j in range(1, i + 1):
				print(c, end=' ')
				c += 1
			print()


class Solution:

	def printFloydTriangle(self, n):
		start = 1
		for i in range(1, n + 1):
			for j in range(i):
				print(start, end=' ')
				start += 1
			print()


class Solution:

	def printFloydTriangle(self, N):
		k = 0
		for i in range(1, N + 1):
			for j in range(i):
				k = k + 1
				print(k, end=' ')
			print('')


class Solution:

	def printFloydTriangle(self, N):
		x = 1
		for i in range(1, N + 1):
			for j in range(0, i):
				print(str(x) + ' ', end='')
				x += 1
			print()


class Solution:

	def printFloydTriangle(self, N):
		val = 1
		for i in range(1, N + 1):
			for i in range(1, i + 1):
				print(val, end=' ')
				val += 1
			print('')


class Solution:

	def printFloydTriangle(self, N):
		counter = 1
		for i in range(N):
			for j in range(i + 1):
				print(counter, end=' ')
				counter += 1
			print()
		return


class Solution:

	def printFloydTriangle(self, N):
		num = 1
		for i in range(0, N):
			for j in range(0, i + 1):
				print(num, end=' ')
				num += 1
			print('\n', end='')


class Solution:

	def printFloydTriangle(self, N):
		no = 1
		for i in range(1, N + 1):
			count = 0
			while count != i:
				if count == i - 1:
					print(no)
				else:
					print(no, end=' ')
				no += 1
				count += 1


class Solution:

	def printFloydTriangle(self, N):
		var = 1
		num = 1
		while var != N + 1:
			for i in range(0, var):
				print(num, end=' ')
				num = num + 1
			var += 1
			print('')


class Solution:

	def printFloydTriangle(self, N):
		count = 1
		for i in range(N):
			for j in range(N):
				if i >= j:
					print(count, end=' ')
					count += 1
			print()


class Solution:

	def printFloydTriangle(self, N):
		val = 1
		for row in range(1, N + 1):
			for col in range(1, row + 1):
				print(val, end=' ')
				val += 1
			print()


class Solution:

	def printFloydTriangle(self, N):
		l = list(range(1, int(N * (N + 1) / 2 + 1)))
		for i in range(N):
			print(*l[int(i * (i + 1) / 2):int((i + 1) * (i + 2) / 2)])


class Solution:

	def printFloydTriangle(self, N):
		row = 1
		num = 1
		while row != N + 1:
			for x in range(row):
				print(num, end=' ')
				num += 1
			print()
			row += 1


class Solution:

	def printFloydTriangle(self, N):
		j = 0
		for i in range(1, N + 1):
			for _ in range(i):
				print(i + j, end=' ')
				j += 1
			j -= 1
			print()
		return


class Solution:

	def printFloydTriangle(self, N):
		(i, count) = (1, 1)
		while i <= N:
			j = 1
			while j <= i:
				print(count, end=' ')
				count += 1
				j += 1
			i += 1
			print(end='\n')


class Solution:

	def printFloydTriangle(self, N):
		i = 1
		j = 1
		while i <= N * (N + 1) // 2 and j <= N:
			for k in range(j):
				print(i, end='\n' if k == j - 1 else ' ')
				i += 1
			j += 1


class Solution:

	def printFloydTriangle(self, N):
		i = 0
		for x in range(1, N + 1):
			for y in range(x):
				i += 1
				print(i, end=' ')
			print()


class Solution:

	def printFloydTriangle(self, N):
		i = 1
		p = 1
		while i <= N:
			j = 1
			while j <= i:
				print(p, end=' ')
				p += 1
				j += 1
			print()
			i += 1