Draw Number Pattern in java
1
12
123
1234
12345
public class Pattern
{
public static void main(String args[]){
for(int i=1;i<=5;i++){
for(int j=1;j<=i;j++){
System.out.print(j);
}
System.out.println();
}
}
}
1
22
333
4444
55555
public class Pattern
{
public static void main(String args[]){
for(int i=1;i<=5;i++){
for(int j=1;j<=i;j++){
System.out.print(i);
}
System.out.println();
}
}
}
55555
4444
333
22
1
public class Pattern
{
public static void main(String args[]){
for(int i=5;i>=1;i--){
for(int j=1;j<=i;j++){
System.out.print(i);
}
System.out.println();
}
}
}
12345
1234
123
12
1
public class Pattern
{
public static void main(String args[]){
for(int i=5;i>=1;i--){
for(int j=1;j<=i;j++){
System.out.print(j);
}
System.out.println();
}
}
}
Comments
Post a Comment