Pattern 1 :
1
1 2
1 2 3
1 2 3 4
1 2 3 45
1 2 3 456
1 2 3 4567
Java Program :
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
//Close the resources
sc.close();
}
}
Output :
How many rows you want in this pattern?
7
Here is your pattern….!!!
1
12
123
1234
12345
123456
1234567
Pattern 2 :
1
2 2
3 3 3
4 4 4 4
5 5 5 55
6 6 6 666
7 7 7 7777
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print(i+" ");
}
System.out.println();
}
//Close the resources
sc.close();
}
}
Java Program :
Output :
How many rows you want in this pattern?
7
Here is your pattern….!!!
1
22
333
4444
55555
666666
7777777
Pattern 3 :
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 56
1 2 3 4 567
1 2 3 4 56
1 2 3 4 5
1 2 3 4
1 2 3
12
1
Java Program :
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
//Printing upper half of the pattern
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
//Printing lower half of the pattern
for (int i = rows-1; i >= 1; i--)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
//Closing the resources
sc.close();
}
}
Output :
How many rows you want in this pattern?
7
Here is your pattern….!!!
1
12
123
1234
12345
123456
1234567
123456
12345
1234
123
12
1
Pattern 4 :
1 2 3 4567
1 2 3 456
1 2 3 45
1 2 3 4
1 2 3
1 2
1
Java Program :
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i = rows; i >= 1; i--)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
//Closing the resources
sc.close();
}
}
Output :
How many rows you want in this pattern?
7
Here is your pattern….!!!
1234567
123456
12345
1234
123
12
1
[quads id=5]
Pattern 5 :
7654321
765432
76543
7654
765
76
7
Java Program :
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i = 1; i <= rows; i++)
{
for (int j = rows; j >= i; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
//Closing the resources
sc.close();
}
}
Output :
How many rows you want in this pattern?
7
Here is your pattern….!!!
7654321
765432
7 6543
7 654
7 65
7 6
7
Pattern 6 :
7
7 6
7 6 5
7 6 5 4
7 6 5 43
7 6 5 432
7 6 5 4321
Java Program :
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i = rows; i >= 1; i--)
{
for (int j = rows; j >= i; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
//Closing the resources
sc.close();
}
}
Output :
How many rows you want in this pattern?
7
Here is your pattern….!!!
7
76
765
7654
76543
765432
7654321
Pattern 7 :
7 6 5 4321
6 5 4 321
5 4 3 21
4 3 2 1
3 2 1
2 1
1
Java Program :
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i = rows; i >= 1; i--)
{
for (int j = i; j >= 1; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
//Closing the resources
sc.close();
}
}
Output :
How many rows you want in this pattern?
7
Here is your pattern….!!!
7654321
654321
54321
4321
321
21
1
Pattern 8 :
1 2 3 4567
1 2 3 456
1 2 3 45
1 2 3 4
1 2 3
1 2
1
1 2
1 2 3
1 2 3 4
1 2 3 45
1 2 3 456
1 2 3 4567
Java Program :
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
//Printing upper half of the pattern
for (int i = rows; i >= 1; i--)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
//Printing lower half of the pattern
for (int i = 2; i <= rows; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
//Closing the resources
sc.close();
}
}
Output :
How many rows you want in this pattern?
7
Here is your pattern….!!!
1234567
123456
12345
1234
123
12
1
12
123
1234
12345
123456
1234567
Pattern 9 :
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 321
1 2 3 4 5 6 54321
1 2 3 4 5 6 7654321
Java Program :
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i = 1; i <= rows; i++)
{
//Printing first half of the row
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
//Printing second half of the row
for (int j = i-1; j >= 1; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
//Closing the resources
sc.close();
}
}
Output :
How many rows you want in this pattern?
7
Here is your pattern….!!!
1
121
12321
1234321
123454321
12345654321
1234567654321
Pattern 10 :
1
2 1
3 2 1
4 3 2 1
5 4 3 21
6 5 4 321
7 6 5 4321
Java Program :
import java.util.Scanner;
public class MainClass
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
//Taking rows value from the user
System.out.println("How many rows you want in this pattern?");
int rows = sc.nextInt();
System.out.println("Here is your pattern....!!!");
for (int i = 1; i <= rows; i++)
{
for (int j = i; j >= 1; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
//Close the resources
sc.close();
}
}
Output :
How many rows you want in this pattern?
7
Here is your pattern….!!!
1
21
321
4321
54321
654321
7654321