You are on page 1of 14

Pattern 1 :

1
1 2
1 23
1 23 4
1 23 45
1 23 456
1 23 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 33
4 44 4
5 55 55
6 66 666
7 77 7777

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(i+" ");
}

System.out.println();
}

//Close the resources

sc.close();
}
}

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 23
1 234
1 2345
1 23456
1 234567
1 23456
1 2345
1 234
1 23
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....!!!");

//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 23 4567
1 23 456
1 23 45
1 23 4
1 23
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

Pattern 5 :
7 65 4321
7 65 432
7 65 43
7 65 4
7 65
7 6
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
76543
7654
765
76
7

Pattern 6 :
7
7 6
7 65
7 65 4
7 65 43
7 65 432
7 65 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 65 4321
6 54 321
5 43 21
4 32 1
3 21
21
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 234567
1 23456
1 2345
1 234
1 23
1 2
1
1 2
1 23
1 23 4
1 23 45
1 23 456
1 23 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 21
1 23 21
1 23 4321
1 23 454321
1 23 45654321
1 23 4567654321

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
21
321
4321
54321
654321
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++)


{
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

You might also like