Update appNew update is available. Click here to update.
sidenav-btnClose
Topic list
Can You Print
EASY
12 mins
3 upvotes
Other topics
Problem solved
Badge
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
Linked List
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
userLevel
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

Can You Print

Contributed by
KAPEESH UPADHYAY
Easy
yellow-spark
0/40
Avg time to solve 12 mins
Success Rate 96 %
Share
3 upvotes

Problem Statement

You are given an integer ‘N’. You have to print integers from 1 to N.

For Example:
Input: 'N' = 6

Output: 1 2 3 4 5 6

If 'N' = 6, The numbers from 1 to 6 are 1, 2, 3, 4, 5, 6.
Hence, the output will be 1 2 3 4 5 6.
Detailed explanation ( Input/output format, Notes, Constraints, Images )
Sample Input 1 :
2
6
2
Sample output 1 :
1 2 3 4 5 6
1 2
Explanation For Sample Output 1 :
For the first test case:
N = 6 
The numbers from 1 to 6 are 1, 2, 3, 4, 5, 6.
Hence, the output will be 1 2 3 4 5 6.

For the second test case:
N = 2 
The numbers from 1 to 2 are 1, 2.
Hence, the output will be 1 2.
Sample Input 2 :
2
3
4
Sample output 2 :
1 2 3
1 2 3 4
Reset Code
Full screen
Auto
copy-code
Console