
use nested loops that print the following patterns in four separate program.
Pattern1 1 12 123 1234 12345 123456
Pattern2 123456 12345 1234 123 12 1
Pattern3 1 21 321 4321 54321 654321
Pattern4 123456 12345 1234 123 12 1

Java Number Patterns
1)
1
12
123
1234
12345
123456
public class PatternExample{
public static void main(String[] args){
for(int i=1;i<=6;i++){
for(int j=1;j<i+1;j++){
System.out.print(j);
}
System.out.println();
}
}
}
2)
123456
12345
1234
123
12
1
public class PatternExample{
public static void main(String[] args){
for(int i=6;i>=1;i--){
for(int j=1;j<i+1;j++){
System.out.print(j);
}
System.out.println();
}
}
}
3)
1
21
321
4321
54321
654321
public class PatternExample{
public static void main(String[] args){
for (int i = 1; i <= 6; i++) {
for (int j = i; j > 0; j--) {
System.out.print("" + j);
}
System.out.println("");
}
}
}
4)
123456
12345
1234
123
12
1
public class PatternExample{
public static void main(String[] args){
for (int i = 6; i > 0; i--) {
for (int j = i; j > 0; j--) {
System.out.print("" + j);
}
System.out.println("");
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.