You are given an integer N. Print numbers from 1 to N without the help of loops.
Example 1:
Input:
N = 5
Output:
1 2 3 4 5
Explanation:
We have to print numbers from 1 to 5.
Example 2:
Input:
N = 10
Output:
1 2 3 4 5 6 7 8 9 10
Explanation:
We have to print numbers from 1 to 10.
Your Task:  
You don't need to read input. Your task is to complete the function printTillN() which takes an integer N as an input parameter and print numbers from 1 to N space-separated integers without the help of loops.
Note: print newline character at the end.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
Constraints:
1 ≤ N ≤ 1000

Source: geeksforgeeks | Difficulty: EASY
Tags: Complete search

Starter code: #User function Template for python3



class Solution:

    def printTillN(self, N):

    	#code here 

Solutions:
class Solution:

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


class Solution:

	def printTillN(self, N):
		if N < 1:
			return
		self.printTillN(N - 1)
		print(N, end=' ')


class Solution:

	def printTillN(self, N):
		if N == 0:
			return
		else:
			self.printTillN(N - 1)
			print(N, end=' ')


class Solution:

	def printTillN(self, N):

		def disp(N, n):
			print(n, end=' ')
			if N > n:
				return disp(N, n + 1)
			else:
				return
		disp(N, 1)


class Solution:

	def printTillN(self, N):

		def sol(x):
			if x > N:
				return
			else:
				print(x, end=' ')
				sol(x + 1)
		return sol(1)


class Solution:

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


class Solution:

	def printTillN(self, N):
		if N == 1:
			print(1, end=' ')
		else:
			ob.printTillN(N - 1)
			print(N, end=' ')


class Solution:

	def print_recur(self, N, m):
		if m == N:
			print(m, end='')
		else:
			print(m, end=' ')
			self.print_recur(N, m + 1)

	def printTillN(self, N):
		self.print_recur(N, 1)


class Solution:

	def printTillN(self, N):
		if N > 0:
			self.printTillN(N - 1)
			print(N, end=' ')


import sys

class Solution:

	def printTillN(self, N):
		if N > 1:
			self.printTillN(N - 1)
		print(N, end=' ')


class Solution:

	def printTillN(self, n):
		if n == 0:
			return
		self.printTillN(n - 1)
		print(n, end=' ')
		return


class Solution:

	def printTillN(self, n):
		i = 1
		while i <= n:
			print(i, end=' ')
			i += 1


class Solution:

	def printTillN(self, N):
		print(*range(1, N + 1), end=' ')


class Solution:

	def printTillN(self, n):
		ans = [print(i, end=' ') for i in range(1, n + 1)]
		return ans


class Solution:

	def printTillN(self, N):

		def rec(N, a):
			if a <= N:
				print(a, end=' ')
				return rec(N, a + 1)
		rec(N, 1)


class Solution:

	def printTillN(self, N):
		i = 1
		self.print_no(i, N)

	def print_no(self, i, N):
		if i <= N:
			print(i, end=' ')
			self.print_no(i + 1, N)


class Solution:

	def printTillN(self, N):
		i = 1
		for i in range(0, N):
			print(i + 1, end=' ')
			i = i + 1
			if i == N:
				break


class Solution:

	def printTillN(self, N):

		def help(n, N):
			if n == N:
				print(n, end=' ')
				return
			print(n, end=' ')
			help(n + 1, N)
		help(1, N)


class Solution:

	def printTillN(self, N):

		def fun(i):
			if i > N:
				return
			print(i, end=' ')
			fun(i + 1)
		fun(1)