Number Pattern Programming Concept is a very interesting one if we consider as a game of numbers associated with coding. It’s a very simple programming concept. The first and foremost thing that one needs to expertise in the ground of number pattern is the proper concept of the loops.

More precisely one needs to understand the concept of  “for”-loop properly to know the technique of doing Number Pattern Programs properly.

Other pre-requisite things to expertise on Number Patters are-

•Proper knowledge of variables, operands, operators, and expressions in any of the coding languages like C, Java, C++, Python. So lets first understand the “for”-loop structure to know how to succeed on doing number patterns in a proper way-

STRUCTURE OF “FOR”-LOOP

for(expression1 ; expression2 ; expression3)

statement;

for(expression1 ; expression2 ; expression3)

{ statement; statement;

… … … ;

}

The loop can be a single statement or block of  statements.

• expression1 refers to an initialization expression. This expression is generally an assignment expression.

• expression2 refers to a test expression or condition and is tested before each iteration of the loop. This condition generally uses relational and logical operators.

• expression3 is an update expression and is executed each time after the body of the loop is executed. Now let us see how this loop works.

Step 1 :

Firstly the initialization expression is executed and the loop variables are initialized.

Step 2 :

Then the codition is checked

•If  the codition is true then the body of  the loop is executed.

Step 3 :

After executing the loop body control transfers to expression3(update expression) and it modifies loop variables.

•Condition is checked and if  it is true, the body of  loop is executed.

Step 4 :

Repeat 2 and 3 till the condition is true and when the condition becomes false the loop is terminated and control is transferred to the statement following the loop.

C NUMBER PATTERNS

Some of  the C Number Patterns are given below-

12345

1234

123

12

1

#include <stdio.h>int main(){int i, j;f or(i=5;i>=1;i--){f or(j=1;j<=i;j++){printf ("%d",j);}printf ("\\n");}return 0;}

#include <stdio.h>

int main()

{

int i, j;

f or(i=5;i>=1;i–)

{

f or(j=1;j<=i;j++)

{

printf (“%d”,j);

}

printf (“\\n”);

}

return 0;

}

12345

2345

345

45

5

#include <stdio.h>

int main()

{

int i, j;

f or(i=1;i<=5;i++)

{

f or(j=i;j<=5;j++)

{

printf (“%d”,j);

}

printf (“\\n”);

}

return 0;

}

54321

4321

321

21

1

#include <stdio.h>

int main()

{

int i, j;

f or(i=5;i>=1;i–)

{

f or(j=i;j>=1;j–)

{

printf (“%d”,j);

}

printf (“\\n”);

}

return 0;

}

54321

5432

543

54

5

#include <stdio.h>

int main()

{

int i, j;

f or(i=1;i<=5;i++)

{

f or(j=5;j>=i;j–)

1

12

123

1234

12345

#include <stdio.h>

int main()

{

int i, j;

f or(i=1;i<=5;i++)

{

f or(j=1;j<=i;j++)

{

printf (“%d”,j);

}

printf (“\\n”);

}

return 0;

}

5

45

345

2345

12345

#include <stdio.h>

int main()

{

int i, j;

f or(i=5;i>=1;i–)

{

f or(j=i;j<=5;j++)

{

printf (“%d”,j);

}

printf (“\\n”);

}

return 0;

}

1

21

321

4321

54321

#include <stdio.h>

int main()

{

int i, j;

f or(i=1;i<=5;i++)

{

f or(j=i;j>=1;j–)

return 0;

}

5

54

543

5432

54321

#include <stdio.h>

int main()

{

int i, j;

f or(i=5;i>=1;i–)

{

f or(j=5;j>=i;j–)

{

printf (“%d”,j);

}

printf (“\\n”);

}

return 0;

}

1

22

333

4444

55555

#include <stdio.h>

int main()

{

int i, j;

f or(i=1;i<=5;i++)

{

f or(j=1;j<=i;j++)

{

printf (“%d”,i);

}

printf (“\\n”);

}

return 0;

}

5

44

333

2222

11111

#include <stdio.h>

int main()

{

int i, j;

f or(i=5;i>=1;i–)

{

f or(j=5;j>=i;j–)

}

return 0;

}

55555

4444

333

22

1

#include <stdio.h>

int main()

{

int i, j;

f or(i=5;i>=1;i–)

{

f or(j=1;j<=i;j++)

{

printf (“%d”,i);

}

printf (“\\n”);

}

return 0;

}

11111

2222

333

44

5

#include <stdio.h>

int main()

{

int i, j;

f or(i=1;i<=5;i++)

{

f or(j=5;j>=i;j–)

{

printf (“%d”,i);

}

printf (“\\n”);

}

return 0;

}

12345

4321

123

21

1

int main()

{

int i,j,k;

f or(i=5;i>=1;i–)

{

if (i%2==1) k=1;

printf (“%d”,k);

if (i%2==1) k++;

else k–;

}

printf (“\\n”);

}

return 0;

}

1234567

12345

123

1

int main()

{

int i,j;

f or(i=7;i>=1;i-=2)

{

f or(j=1;j<=i;j++)

{

printf (“%d”,j);

}

printf (“\\n”);

}

return 0;

}

1

01

101

0101

#include <stdio.h>

int main()

{

int i, j;

f or(i=1;i<=4;i++)

{

f or(j=i;j>=1;j–)

{

printf (“%d”,j%2);

}

printf (“\\n”);

}

return 0;

}

13579

3579

579

79

9

#include <stdio.h>

int main()

{

int i,j;

f or(i=1;i<=9;i+=2)

{

f or(j=i;j<=9;j+=2)

{

printf (“%d”,j);

}

return 0;

}

1

2 4

1 3 5

2 4 6 8

1 3 5 7 9

#include<stdio.h>

int main()

{

int i,j,k;

f or(i=1;i<=5;i++)

{

if (i%2==0)

{

k=2;

}

else

{

k=1;

}

f or(j=1;j<=i;j++,k+=2)

{

printf (“%d “, k);

}

printf (“\\n”);

}

return 0;

}

55555

45555

34555

23455

12345

int main()

{

int i, j, k;

f or(i=5;i>=1;i–)

{

k = i;

f or(j=1;j<=5;j++)

{

if (k <= 5)

{

printf (“%d”,k);

}

else

{

printf (“5”);

}

k++;

}

printf (“\\n”);

}

return 0;

}

1

23

456

78910

#include<stdio.h>

int main()

{

int i,j,k;

k=1;

f or(i=1;i<5;i++)

{

f or(j=1;j<=i;j++)

{

printf (“%d”,k++);

}

printf (“\\n”);

}

return 0;

}

12344321

123**321

12****21

1******1

#include<stdio.h>

int main()

{

int i,j,k;

f or(i=4;i>=1;i–)

{

f or(j=1;j<=4;j++)

{

if (j<=i)

printf (“%d”,j);

else

printf (” “);

}

f or(j=4;j>=1;j–)

{

if (j<=i)

printf (“%d”,j);

else

printf (” “);

}

printf (“\\n”);

}

return 0;

}

1

2 3 4

5 6 7 8 9

#include<stdio.h>

int main()

{

int i,j,k;

k=1;

f or(i=1;i<=5;i+=2)

{

f or(j=5;j>=1;j–)

{

if (j>i)

printf (” “);

else

printf (“%d “,k++);

}

printf (“\\n”);

}

return 0;

}

1   2   3   4   5   6   7   8   9   10

36  37  38  39  40  41  42  43  44  11

35  64  65  66  67  68  69  70  45  12

34  63  84  85  86  87  88  71  46  13

33  62  83  96  97  98  89  72  47  14

32  61  82  95  100 99  90  73  48  15

31  60  81  94  93  92  91  74  49  16

30  59  80  79  78  77  76  75  50  17

29  58  57  56  55  54  53  52  51  18

28  27  26  25  24  23  22  21  20  19

#include<stdio.h>

int main()

{

int a[10][10]={0},i,j,low=0,top=9,n=1;

f or(i=0;i<5;i++,low++,top–)

{

f or(j=low;j<=top;j++,n++)

a[i][j]=n;

f or(j=low+1;j<=top;j++,n++)

a[j][top]=n;

f or(j=top-1;j>=low;j–,n++)

a[top][j]=n;

f or(j=top-1;j>low;j–,n++)

a[j][low]=n;

}

printf (“\\t\\t\\t\\tPerf ect Square\\n”);

f or(i=0;i<10;i++)

{

printf (“\\n\\n\\t”);

f or(j=0;j<10;j++)

{

printf (“%6d”,a[i][j]);

delay(300);

}

}

return 0;

}11111

2222

333

22

1

#include<stdio.h>

int main()

{

int i,j;

f or(i=1;i<=5;i++)

{

f or(j=5;j>=i;j–)

{

if (i<=3)

printf (“%d”,i);

else

printf (“%d”,6-i);

}

printf (“\\n”);

}

return 0;

}

5432*

543*1

54*21

5*321

*4321

#include<stdio.h>

int main()

{

int i,j;

f or(i=1;i<=5;i++)

{

f or(j=5;j>=1;j–)

{

if (i==j) printf (“*”); else

printf (“%d”,j);

}

printf (“\\n”);

}

return 0;

}

1

121

12321

1234321

#include<stdio.h>

int main()

{

int i,j;

f or(i=1;i<=4;i++)

{

f or(j=1;j<=i;j++)

printf (“%d”,j);

f or(j=i-1;j>=1;j–) printf (“%d”,j); printf (“\\n”);

}

return 0;

}

0

909

89098

7890987

678909876

56789098765

4567890987654

345678909876543

23456789098765432

1234567890987654321

#include<stdio.h>

int main()

{

int i,j;

printf (“0\\n”);

f or(i=9;i>=1;i–)

{

f or(j=i;j<=9;j++) printf (“%d”,j); printf (“0”);

f or(j=9;j>=i;j–) printf (“%d”,j); printf (“\\n”);

}

return 0;

}

1        1

12      21

123    321

1234  4321

1234554321

#include<stdio.h>

int main()

{

int i,j,k;

f or(i=1;i<=5;i++)

{

f or(j=1;j<=5;j++)

{

if (j<=i)

printf (“%d”,j);

else

printf (” “);

}

f or(j=5;j>=1;j–)

{

if (j<=i)

printf (“%d”,j);

else

printf (” “);

}

printf (“\\n”);

}

return 0;

}

1

21

321

4321

54321

#include<stdio.h>

int main()

{

int i,j,k;

f or(i=1;i<=5;i++)

{

f or(j=5;j>=1;j–)

{

if (j<=i)

printf (“%d”,j);

else

printf (” “);

}

printf (“\\n”);

}

return 0;

}

1

232

45654

78910987

#include<stdio.h>

int main()

{

int i,j,k=1,l=1,n=4;

f or(i=1;i<=n;i++)

{

l=k;

f or(j=1;j<=i;j++) printf (“%d”,l++); k=l–;

f or(j=1;j<i;j++) printf (“%d”,–l); printf (“\\n”);

}

return 0;

}

1

232

45654

78910987

#include<stdio.h>

int main()

{

int i,j,k=1,l=1,n=4;

f or(i=1;i<=n;i++)

{

l=k;

f or(j=1;j<=i;j++) printf (“%d”,l++); k=l–;

f or(j=1;j<i;j++) printf (“%d”,–l); printf (“\\n”);

}

return 0;

}

1

2*2

3*3*3

4*4*4*4

4*4*4*4

3*3*3

2*2

1

#include<stdio.h>

int main()

{

int i,j;

f or(i=1;i<=4;i++)

{

f or(j=1;j<=i;j++)

{

if (j<i)

printf (“%d*”,i);

else

printf (“%d”,i);

}

printf (” \\n”);

}

f or(i=4;i>=1;i–)

{

f or(j=1;j<=i;j++)

{

if (j<i)

printf (“%d*”,i);

else

printf (“%d”,i);

}

printf (” \\n”);

}

return 0;

}

11

12 13

13 14 15

14 15 16 17

#include <stdio.h>

int main()

{

int i,j;

f or(i=1;i<=4;i++)

{

f or(j=1;j<=i;j++)

{

printf (“%d “, 9+i+j);

}

printf (“\\n”);

}

return 0;

}

1

2 3

4 5 6

7 8 9 10

#include<stdio.h>

int main()

{

int i,j,k;

k=1;

f or(i=1;i<=5;i++)

{

f or(j=5;j>=1;j–)

{

if (j > i)

printf (”   “);

else

printf (“%3d”,k++);

}

printf (“\\n”);

}

return 0;

}

5

54

543

5432

54321

int main()

{

int i,j;

f or(i=5;i>=1;i–)

{

f or(j=1;j<i;j++)

printf (” “);

f or(j=5;j>=i;j–) printf (“%d”,j); printf (“\\n”);

}

return 0;

}

1

212

32123

4321234

#include<stdio.h>

int main()

{

int i,j;

f or(i=1;i<=4;i++)

{

f or(j=i;j>1;j–)

printf (“%d”,j);

f or(j=1;j<=i;j++) printf (“%d”,j); printf (“\\n”);

}

return 0;

}

1

23

345

56789

#include<stdio.h>

int main()

{

int i,j,k;

f or(i=1;i<=5;i++)

{

j=i;

f or(k=1;k<=i;k++)

{

printf (“%d”,j++);

}

printf (“\\n”);

}

return 0;

}

1  2  3  4  5

6  7  8  9

10 11 12

13 14

15

#include<stdio.h>

int main()

{

int i,j,k;

k=1;

f or(i=1;i<=5;i++)

{

f or(j=5;j>=i;j–)

{

printf (“%3d”,k++);

}

printf (“\\n”);

}

return 0;

}

1234

2341

3421

4321

int main()

{

int i,j,k;

f or(i=1;i<=4;i++)

{

k = i-1;

f or(j=i;j<i+4;j++)

{

if (j<=4)

{

printf (“%d”,j);

}

else

{

printf (“%d”,k–);

}

}

printf (“\\n”);

}

return 0;

}

11111

0000

111

00

1

#include <stdio.h>

int main()

{

int i, j;

f or(i=5;i>=1;i–)

{

f or(j=1;j<=i;j++)

{

printf (“%d”,i%2);

}

printf (“\\n”);

}

return 0;

}

1

4   9  16

25  36  49  64  81

100 121 144 169 196 225 256

289 324 361 400 441 484 529 576 625

#include<stdio.h>

int main()

{

int i, j, k=1;

f or(i=1;i<=5;i++)

{

f or(j=i;j<5;j++)

{

printf (”    “);

}

f or(j=1;j<(i*2);j++)

{

printf (“%3d “,k*k);

k++;

}

printf (“\\n”);

}

return 0;

}

11111

1   1

1   1

1   1

11111

#include<stdio.h>

int main()

{

int i,j;

f or(i=1;i<=5;i++)

{

f or(j=1;j<=5;j++)

{

if (j==5 || j==1 || i==1 || i==5)

printf (“1”);

else

printf (” “);

}

printf (“\\n”);

}

return 0;

}

1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

#include<stdio.h>

int main()

{

int i,j;

f or(i=1;i<=5;i++)

{

f or(j=5;j>i;j–)

{

printf (” “);

}

f or(j=1;j<=i;j++)

{

printf (“%d “,j);

}

printf (“\\n”);

}

return 0;

}

1

123

12345

1234567

123456789

1234567

12345

123

1

#include<stdio.h>

int main()

{

int i, j, k;

f or(i=1;i<=5;i++)

{

f or(j=i;j<5;j++)

{

printf (” “);

}

f or(k=1;k<(i*2);k++)

{

printf (“%d”,k);

}

printf (“\\n”);

}

f or(i=4;i>=1;i–)

{

f or(j=5;j>i;j–)

{

printf (” “);

}

f or(k=1;k<(i*2);k++)

{

printf (“%d”,k);

}

printf (“\\n”);

}

return 0;

}

*000*000*

0*00*00*0

00*0*0*00

000***000

int main()

{

int i,j,k;

f or(i=1;i<=4;i++)

{

f or(j=1;j<=9;j++)

{

if (j==i || j==5 || 10-j==i)

printf (“*”);

else

printf (“0”);

}

printf (“\\n”);

}

return 0;

}

5 5 5 5 5 5 5 5 5

5 4 4 4 4 4 4 4 5

5 4 3 3 3 3 3 4 5

5 4 3 2 2 2 3 4 5

5 4 3 2 1 2 3 4 5

5 4 3 2 2 2 3 4 5

5 4 3 3 3 3 3 4 5

5 4 4 4 4 4 4 4 5

5 5 5 5 5 5 5 5 5 int main()

{

int i, j, n=5;

f or(i=n; i>1; i–)

{

f or(j=n;j>=1;j–)

{

if (j>i) printf (“%d “, j);

else printf (“%d “, i);

}

f or(j=2;j<=n;j++)

{

if (j>i) printf (“%d “, j);

else printf (“%d “, i);

}

printf (“\\n”);

}

f or(i=1; i<=n; i++)

{

f or(j=n;j>=1;j–)

{

if (j>i) printf (“%d “, j);

else printf (“%d “, i);

}

f or(j=2;j<=n;j++)

{

if (j>i) printf (“%d “, j);

else printf (“%d “, i);

}

printf (“\\n”);

}

return 0;

}

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

long f act(int);

int main()

{

int i, j;

f or (i=0;i<5;i++)

{

f or(j=0;j<=i;j++)

{

printf (“%ld “,f act(i)/(f act(j)*f act(i-j)));

}

printf (“\\n”);

}

return 0;

}

long f act(int n)

{

int i;

long f  = 1;

f or(i=1;i<=n;i++)

f  = f *i;

return f ;

}

1

2 4

3 6 9

4 8 12 16

5 10 15 20 25

6 12 18 24 30 36

7 14 21 28 35 42 49

8 16 24 32 40 48 56 64

9 18 27 36 45 54 63 72 81

10 20 30 40 50 60 70 80 90 100

int main()

{

int i,j;

f or(i=1;i<=10;i++)

{

f or(j=1;j<=i;j++)

{

printf (“%d “,i*j);

}

printf (“\\n”);

}

return 0;

}

1

1 2

3 5 8

13 21 34 55

89 144 233 377 610

#include<stdio.h>

int f ib(int);

int main()

{

int i,j,k=1;

f or(i=1;i<=5;i++)

{

f or(j=1;j<=i;j++)

{

printf (“%d “,f ib(k++));

}

printf (“\\n”);

}

return 0;

}

int f ib(int n)

{

if (n<=1)

return n;

return(f ib(n-1)+f ib(n-2));

}

11111

10001

10001

10001

11111

#include<stdio.h>

int main()

{

int i,j;

f or(i=1;i<=5;i++)

{

f or(j=1;j<=5;j++)

{

if (j==5 || j==1 || i==1 || i==5)

printf (“1”);

else

printf (“0”);

}

printf (“\\n”);

}

return 0;

}

JAVA PATTERNS

Some of  the Java Patterns are given below- Pattern 1 :

1

22

333

4444

55555

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j;

Scanner s=new Scanner(System.in);

System.out.print(“Enter the below 10 number of  rows you want to print pattern :”);

int n = s.nextInt();

f or(i=1;i<=n;i++)

{

f or(j=1;j<=i;j++)

{

System.out.print(” “+i+” “);

}

System.out.print(“\\n”);

}

}

}

Pattern 2

5

44

333

2222

11111

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,x;

Scanner s = new Scanner(System.in); System.out.print(“enter no.below 10 till you have pattern :”); int n =s.nextInt();

x=n;

f or(i=1;i<=n;i++)

{  f or(j=1;j<=i;j++)

{

System.out.print(” “+x+” “);

} System.out.print(“\\n”);

x=x-1;

}

}

}

Pattern 3

11111

2222

333

44

5

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k;

Scanner  s=new Scanner(System.in);

System.out.print(“enter no. below 10 you should have pattern :”);

int n=s.nextInt();

f or(i=1;i<=n;i++)

{

f or(j=i;j<=n;j++)

{

System.out.print(” “+i);

}

System.out.print(“\\n”);

}

}

}

Pattern 4

55555

4444

333

22

1

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k,x;

Scanner s = new Scanner(System.in); System.out.print(“enter no. below 10 you have pattern :”); int n = s.nextInt();

x=n;

f or(i=1;i<=n;i++)

{

f or(j=i;j<=n;j++)

{

System.out.print(” “+x);

}

System.out.print(“\\n”);

x=x-1;

}

}

}

Pattern 5

1

22

333

4444

55555

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k;

Scanner s = new Scanner(System.in);

System.out.print(“enter no. below 10 till you have pattern :”);

int n=s.nextInt();

f or(i=1;i<=n;i++)

{

f or(k=1;k<=n-i;k++)

{

System.out.print(” “);

}

f or(j=1;j<=i;j++)

{

System.out.print(i);

}

System.out.print(“\\n”);

}

}

}

Pattern 6

5

44

333

2222

11111

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k,x;

Scanner s = new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n = s.nextInt();

x=n;

f or(i=1;i<=n;i++)

{

f or(k=1;k<=n-i;k++)

{

System.out.print(” “);

}

f or(j=1;j<=i;j++)

{

System.out.print(x);

} System.out.print(“\\n”); x=x-1;

}

}

}

Pattern 7

1

2 2

3 3 3

4 4 4 4

5 5 5 5 5

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k;

Scanner s=new Scanner(System.in);

System.out.print(“enter no. below 10 till you have pattern :”);

int n =s.nextInt();

f or(i=1;i<=n;i++)

{

f or(k=1;k<=n-i;k++)

{

System.out.print(” “);

}

f or(j=1;j<=i;j++)

{

System.out.print(” “+i);

}

System.out.print(“\\n”);

}

}

}

Pattern 8

5

4 4

3 3 3

2 2 2 2

1 1 1 1 1

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k,x;

Scanner s = new Scanner(System.in); System.out.print(“enter below no.10 till you have pattern”); int n = s.nextInt();

x=n;

f or(i=1;i<=n;i++)

{

f or(k=1;k<=n-i;k++)

{

System.out.print(” “);

}

f or(j=1;j<=i;j++)

{

System.out.print(” “+x);

}

System.out.print(“\\n”);

x=x-1;

}

}

}

Pattern 9

1 1 1 1 1

2 2 2 2

3 3 3

4 4

5

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k;

Scanner s = new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n=s.nextInt();

f or(i=1;i<=n;i++)

{

f or(k=1;k<i;k++)

{

System.out.print(” “);

}

f or(j=i;j<=n;j++)

{

System.out.print(” “+i);

}

System.out.print(“\\n”);

}

}

}

Pattern 10

5 5 5 5 5

4 4 4 4

3 3 3

2 2

1

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k,x;

Scanner s = new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n=s.nextInt();

x=n;

f or(i=1;i<=n;i++)

{

f or(k=1;k<i;k++)

{

System.out.print(” “);

}

f or(j=i;j<=n;j++)

{

System.out.print(” “+x);

}

System.out.print(“\\n”);

x=x-1;

}

}

}

Pattern 11

1 1 1 1 1

2 2 2 2

3 3 3

4 4

5

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k;

Scanner s = new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n=s.nextInt();

f or(i=1;i<=n;i++)

{

f or(k=1;k<i;k++)

{

System.out.print(” “);

}

f or(j=i;j<=n;j++)

{

System.out.print(i);

}

System.out.print(“\\n”);

}

}

}

Pattern 12

55555

4444

333

22

1

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k,x;

Scanner s = new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n = s.nextInt();

x=n;

f or(i=1;i<=n;i++)

{

f or(k=1;k<i;k++)

{

System.out.print(” “);

}

f or(j=i;j<=n;j++)

{

System.out.print(x);

}

System.out.print(“\\n”);

x=x-1;

}

}

}

Pattern 13

11111

22222

33333

44444

55555

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j;

Scanner s=new Scanner(System.in);

System.out.print(“enter below no.10  till you have pattern :”);

int n=s.nextInt();

f or(i=1;i7lt;=n;i++)

{

f or(j=1;j<=n;j++)

{

System.out.print(” “+i+” “);

}

System.out.print(“\\n”);

}

}

}

Pattern 14

55555

44444

33333

22222

11111

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,x;

Scanner s=new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n=s.nextInt();

x=n;

f or(i=1;i7lt;=n;i++)

{

f or(j=1;j<=n;j++)

{

System.out.print(” “+x+” “);

}

System.out.print(“\\n”);

x=x-1;

}

}

}

Pattern 15

1 1 1 1 1

2 2 2 2 2

3 3 3 3 3

4 4 4 4 4

5 5 5 5 5

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k;

Scanner s=new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n=s.nextInt();

f or(i=1;i<=n;i++)

{

f or(j=i;j<=n;j++)

{

System.out.print(” “);

}

f or(k=1;k<=n;k++)

{

System.out.print(” “+i);

}

System.out.print(\\\\n”); } } }

Pattern 16

5 5 5 5 5

4 4 4 4 4

3 3 3 3 3

2 2 2 2 2

1 1 1 1 1

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k,x;

Scanner s=new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n=s.nextInt();

x=n;

f or(i=1;i<=n;i++)

{

f or(j=i;j<=n;j++)

{

System.out.print(” “);

}

f or(k=1;k<=n;k++)

{

System.out.print(” “+x);

}

System.out.print(“\\n”);

x=x-1;

}

}

}

Pattern 17

1 1 1 1 1

2 2 2 2 2

3 3 3 3 3

4 4 4 4 4

5 5 5 5 5

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k;

Scanner s=new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n=s.nextInt();

f or(i=1;i<=n;i++)

{

f or(j=1;j<=i;j++)

{

System.out.print(” “);

}

f or(k=1;k<=n;k++)

{

System.out.print(” “+i);

}

System.out.print(“\\n”);

}

}

}

Pattern 18

5 5 5 5 5

4 4 4 4 4

3 3 3 3 3

2 2 2 2 2

1 1 1 1 1

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k,x;

Scanner s=new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n=s.nextInt();

x=n;

f or(i=1;i<=n;i++)

{

f or(j=1;j<=i;j++)

{

System.out.print(” “);

}

f or(k=1;k<=n;k++)

{

System.out.print(” “+x);

}

System.out.print(“\\n”);

x=x-1;

}

}

}

Pattern 19

5

4 4

3 3 3

2 2 2 2

1 1 1 1 1

2 2 2 2

3 3 3

4 4

5

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k,y;

Scanner s=new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n=s.nextInt();

y=n;

f or(i=1;i<=n;i++)

{

f or(k=1;k<=n-i;k++)

{

System.out.print(” “);

}

f or(j=1;j<=i;j++)

{

System.out.print(” “+y);

}

System.out.print(“\\n”);

y=y-1;

}

f or(i=2;i<=n;i++)

{

f or(k=1;k<i;k++)

{

System.out.print(” “);

}

f or(j=i;j<=n;j++)

{

System.out.print(” “+i);

}

System.out.print(“\\n”);

}

}

}

Pattern 20

1

2 2

3 3 3

4 4 4 4

5 5 5 5 5

4 4 4 4

3 3 3

2 2

1

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k,y;

Scanner s= new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n=s.nextInt();

f or(i=1;i<=n;i++)

{

f or(k=1;k<=n-i;k++)

{

System.out.print(” “);

}

f or(j=1;j<=i;j++)

{

System.out.print(” “+i);

}

System.out.print(“\\n”);

}

y=n-1;

f or(i=2;i<=n;i++)

{

f or(k=1;k<i;k++)

{

System.out.print(” “);

}

f or(j=i;j<=n;j++)

{

System.out.print(” “+y);

}

System.out.print(“\\n”);

y=y-1;

}

}

}

Pattern 21

1

2 2

3 3 3

4 4 4 4

5 5 5 5 5

5 5 5 5 5

4 4 4 4

3 3 3

2 2

1

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k,x;

Scanner s = new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n = s.nextInt();

x=n;

f or(i=1;i<=n;i++)

{

f or(k=1;k<=n-i;k++)

{

System.out.print(” “);

}

f or(j=1;j<=i;j++)

{

System.out.print(i);

}

System.out.print(“\\n”);

}

f or(i=1;i<=n;i++)

{

f or(k=1;k<i;k++)

{

System.out.print(” “);

}

f or(j=i;j<=n;j++)

{

System.out.print(x);

}

System.out.print(“\\n”);

x=x-1;

}

}

}

Pattern 22

5

4 4

3 3 3

2 2 2 2

1 1 1 1 1

1 1 1 1 1

2 2 2 2

3 3 3

4 4

5

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k,x;

Scanner s = new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n = s.nextInt();

x=n;

f or(i=1;i<=n;i++)

{

f or(k=1;k<=n-i;k++)

{

System.out.print(” “);

}

f or(j=1;j<=i;j++)

{

System.out.print(x);

}

System.out.print(“\\n”);

x=x-1;

}

f or(i=1;i<=n;i++)

{

f or(k=1;k<i;k++)

{

System.out.print(” “);

}

f or(j=i;j<=n;j++)

{

System.out.print(i);

}

System.out.print(“\\n”);

}

}

}

Pattern 23

1

2 2

3 3 3

4 4 4 4

5 5 5 5 5

5 5 5 5 5

4 4 4 4

3 3 3

2 2

1

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,x;

Scanner s= new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n =s.nextInt();

x=n;

f or(i=1;i<=n;i++)

{

f or(j=1;j<=i;j++)

{

System.out.print(” “+i);

}

System.out.print(“\\n”);

}

f or(i=1;i<=n;i++)

{

f or(j=i;j<=n;j++)

{

System.out.print(” “+x);

}

System.out.print(“\\n”);

x=x-1;

}

}

}

Pattern 24

5

4 4

3 3 3

2 2 2 2

1 1 1 1 1

1 1 1 1 1

2 2 2 2

3 3 3

4 4

5

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,x;

Scanner s = new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern : “);

int n = s.nextInt();

x=n;

f or(i=1;i<=n;i++)

{

f or(j=1;j<=i;j++)

{

System.out.print(” “+x);

}

System.out.print(“\\n”);

x=x-1;

}

f or(i=1;i<=n;i++)

{

f or(j=i;j<=n;j++)

{

System.out.print(” “+i);

}

System.out.print(“\\n”);

}

}

}

Pattern 25

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

import java.util.Scanner;

class PascalTriangle

{

public static void main(String args[])

{

int r, i, k, number=1, j;

Scanner scan = new Scanner(System.in);

System.out.print(Enter Number of  Rows : );

r = scan.nextInt();

f or(i=0;i<r;i++)

{

f or(k=r; k>i; k–)

{

System.out.print( );

}

number = 1;

f or(j=0;j<=i;j++)

{

System.out.print(number+  );

number = number * (i – j) / (j + 1);

} System.out.println();

}

}

}

Pattern 26

1 1 1 1 1

2      2

3      3

4      4

5 5 5 5 5

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k,l;

Scanner s=new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n = s.nextInt();

f or(i=1;i<=n;i++)

{

if (i==1||i==n)

{

f or(j=1;j<=n;j++)

{

System.out.print(i+” “);

}

System.out.print(“\\n”);

}

else

{

System.out.print(i);

f or(l=2;l<n;l++)

{

System.out.print(”  “);

}

System.out.print(” “+i); System.out.print(“\\n”);

}

}

}

}

Pattern 27

5 5 5 5 5

4       4

3       3

2       2

1 1 1 1 1

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k,l,x;

Scanner s=new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n=s.nextInt();

x=n;

f or(i=1;i<=n;i++)

{

if (i==1||i==n)

{

f or(j=1;j<=n;j++)

{

System.out.print(x+” “);

}

System.out.print(“\\n”);

x=x-1;

}

else

{

System.out.print(x);

f or(l=2;l<n;l++)

{

System.out.print(”  “);

}

System.out.print(” “+x); System.out.print(“\\n”); x=x-1;

}

}

}

}

Pattern 28

1 1 1 1 1

2    2

3    3

4    4

5 5 5 5 5

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,x,j,k,l,m;

Scanner s = new Scanner(System.in);

System.out.println(“enter even no. below 10 till you have pattern :”);

int n = s.nextInt();

f or(i=1;i<=n;i++)

{

if (i==1||i==n)

{

f or(j=1;j<=n;j++)

{

System.out.print(” “+i);

}

System.out.println();

}

else

{

f or (k=1;k<=n/2;k++)

{

System.out.print(” “);

}

System.out.print(i);

f or(l=2;l<n;l++)

{

System.out.print(” “);

}

System.out.print(” “+i); System.out.println();

}

}

}

}

Pattern 29

1 1 1 1 1

2 2 2 2

3 3 3

4 4

5

5

4 4

3 3 3

2 2 2 2

1 1 1 1 1

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,x,k;

Scanner s = new Scanner(System.in); System.out.println(“enter below no. 10 you have patterm :”); int n = s.nextInt();

x=n;

f or(i=1;i<=n;i++)

{

f or(k=1;k<i;k++)

{

System.out.print(” “);

}

f or(j=i;j<=n;j++)

{

System.out.print(i);

}

System.out.println();

}

f or(i=1;i<=n;i++)

{

f or(k=1;k<=n-i;k++)

{

System.out.print(” “);

}

f or(j=1;j<=i;j++)

{

System.out.print(x);

}

System.out.println();

x=x-1;

}

}

}

Pattern 30

5 5 5 5 5 5 5 5 5 5

4 4 4 4   4 4 4 4

3 3 3     3 3 3

2 2       2 2

1          1

import java.util.Scanner;

public class Main

{

public static void main(String[] args)

{

int i,j,k,x,p;

Scanner s = new Scanner(System.in);

System.out.print(“enter below no. 10 till you have pattern :”);

int n = s.nextInt();

f or(i=n;i>=0;i–)

{

f or(k=1;k<=n-i;k++)

{

System.out.print(” “);

}

f or(j=1;j<=i;j++)

{

System.out.print(” “+i);

}

f or(p=1;p<=n-i;p++)

{

System.out.print(”  “);

}

f or(x=1;x<=i;x++)

{

System.out.print(” “+i);

}

System.out.print(“\\n”);

}

}

}

Webtopdfconverter.com