-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b298df
commit 79b2e38
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Print the following pattern | ||
|
||
Pattern for N = 4 | ||
|
||
1 | ||
23 | ||
345 | ||
4567 | ||
|
||
|
||
JAVA CODE:- | ||
|
||
|
||
|
||
import java.util.*; | ||
public class Solution { | ||
|
||
|
||
public static void main(String[] args) { | ||
|
||
/* Your class should be named Solution. | ||
* Read input as specified in the question. | ||
* Print output as specified in the question. | ||
*/ | ||
|
||
Scanner sc=new Scanner(System.in); | ||
int n=sc.nextInt(); | ||
|
||
|
||
int i, j, k; | ||
|
||
for(i=1; i<=n; i++) | ||
{ | ||
k = i; | ||
|
||
// Logic to print numbers | ||
for(j=1; j<=i; j++) | ||
{ | ||
System.out.print(k); | ||
k++; | ||
} | ||
|
||
System.out.println(" "); | ||
|
||
} | ||
|
||
} | ||
} |