Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
1
//'main' method must be in a class 'Rextester'. //openjdk version '11.0.5' import java.util.*; import java.lang.*; class Rextester { // Function to demonstrate printing pattern public static void printNums(int n) { // initialising starting number int i, j, num=1; // outer loop to handle number of rows // n in this case for(i=0; i<n; i++) { // without re assigning num // num = 1; for(j=0; j<=i; j++) { // printing num with a space System.out.print(num+ " "); // incrementing num at each column num = num + 1; } // ending line after each row System.out.println(); } } // Driver Function public static void main(String args[]) { int n = 5; printNums(n); } }
run
|
edit
|
history
|
help
0
2B
4.b
10 Wizards
Union of Arrays
calc exp
forloop
Borrowing class
pass
Rextester.java
191fa07131