How to print the following pattern? Write the program in Java.
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
Please answer fast!!
Answers
Answered by
6
public class Pattern {
public static void main(String[] args) {
int z=1;
for(int i=1; i<=5; i++){
for(int j=1; j<=i; j++){
System.out.print(z + " " );
z++;
}
System.out.println();
}
}
}
public static void main(String[] args) {
int z=1;
for(int i=1; i<=5; i++){
for(int j=1; j<=i; j++){
System.out.print(z + " " );
z++;
}
System.out.println();
}
}
}
Answered by
1
public class print numbers{
public static void main(String args[]){
System.out.println("1")
System.out.println("2"+"3")
System.out.println("4"+"5"+"6")
System.out.println("7"+"8"+"9"+"10")
System.out.println("11"+"12"+"13"+"14"+"15")
}
}
public static void main(String args[]){
System.out.println("1")
System.out.println("2"+"3")
System.out.println("4"+"5"+"6")
System.out.println("7"+"8"+"9"+"10")
System.out.println("11"+"12"+"13"+"14"+"15")
}
}
Similar questions