Pattern Printing in Java

                                                                             
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
 
package programs;

public class PatternProgram1 {

 public static void main(String[] args) {
  for(int i =1;i<=7;i++){
   for(int j =1; j<=i;j++){
    System.out.print(j+" ");
   }
   System.out.println();
  }
 }
}

***************************************************************************************************************


1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
7 7 7 7 7 7 7
 
package programs;

public class PatternProgram2 {

 public static void main(String[] args) {
  for(int i =1;i<=7;i++){
   for(int j =1; j<=i;j++){
    System.out.print(i+" ");
   }
   System.out.println();
  }
 }
}



***************************************************************************************************************
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
 
package programs;

public class PatternProgram3 {


 public static void main(String[] args) {
  for(int i =1; i<=7;i++){
   for(int j =1; j<=i;j++){
    System.out.print(j+" ");
   }
   System.out.println();
  }
  for(int i=6;i>=1;i--){
   for(int j =1; j<=i;j++){
    System.out.print(j+" ");
   }
   System.out.println();
  }
 }
}


*****************************************************************************************************

1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
 
package programs;

import java.util.Scanner;

public class PatternProgram5 {


 public static void main(String[] args) {
 
  Scanner scanner = new Scanner(System.in);
  System.out.println("enter input data");
  int number = scanner.nextInt();
  for(int i=number;i>=1; i--){
   for(int j = 1; j<=i;j++){
    System.out.print("j"+" ");
   }
   System.out.println();
  }
 }
}

***********************************************************************************************************


7 6 5 4 3 2 1
7 6 5 4 3 2
7 6 5 4 3
7 6 5 4
7 6 5
7 6
7
 
package programs;

import java.util.Scanner;

public class PatternProgram6{


 public static void main(String[] args) {
  Scanner scanner = new Scanner(System.in);
  System.out.println("enter input data");
  int number = scanner.nextInt();
  for(int i =1; i<=number;i++){
   for(int j = number; j>=i;j--){
    System.out.print(j+" ");
   }
   System.out.println();
  }
 }
}



*******************************************************************************************************
 
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
  

package programs;

public class PatternProgram7 {


 
 public static void main(String[] args) {
  for(int i =7; i>=1; i--){
   for(int j =1 ; j<=i; j++){
    System.out.print(j+" ");
   }
   System.out.println();
  }
  
  for(int k = 2; k<=7; k++){
   for(int j =1 ; j<=k; j++){
    System.out.print(j+" ");
   }
   System.out.println();
  }
 }
}


**********************************************************************************************
 
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 5 6 5 4 3 2 1
1 2 3 4 5 6 7 6 5 4 3 2 1
 

package programs;

public class PatternProgram8 {


 public static void main(String[] args) {
  for(int i = 1; i<=7; i++){
   
   for(int j = 1; j<=i; j++){
    System.out.print(j+" ");
   }
   
   for(int j = i-1; j>=1; j--){
    System.out.print(j+" ");
   }
   System.out.println();
  }

 }
}