Java Number Pattern Programs
This article is all about of number pattern programs in java. This number pattern program is also a very important from the interview point of view.
Here we will see many java number pattern programs examples.
So let's start with it.
Number Pattern 1 :
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Solution :
Solution :
class Demo1
{
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();
}
}
}
Number Pattern 2 :
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Solution :
Number Pattern 2 :
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Solution :
class Demo2
{
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();
}
}
}
Number Pattern 3 :
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
Solution :
Number Pattern 4 :
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Solution :
Here we are performing number pattern programs in java using for loop. In other words, here we are using nested loop i.e loop inside another loop.
Number Pattern 5 :
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
Solution :
Number Pattern 6 :
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15
Solution :
here another number pattern program in java which will help you in a java programming interviews.
Learn more : Top 10 Frequently asked java number pattern programs - Part 2.
Number Pattern 7 :
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Solution :
Number Pattern 8 :
8 7 6 5 4 3 2 1
8 7 6 5 4 3 2
8 7 6 5 4 3
8 7 6 5 4
8 7 6 5
8 7
8
Solution :
Number Pattern 3 :
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
Solution :
class Demo3
{
public static void main(String args[])
{
for(int i = 1; i<=5; i++)
{
for(int j = i; j>=1; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
}
}Number Pattern 4 :
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Solution :
class Demo4
{
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();
}
}
}Here we are performing number pattern programs in java using for loop. In other words, here we are using nested loop i.e loop inside another loop.
Number Pattern 5 :
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
Solution :
class Demo5
{
public static void main(String args[])
{
for(int i = 1; i <= 5; i++)
{
for(int j = 1; j <=i; j++)
{
System.out.print(j+" ");
}
for(int j = i-1; j >= 1; j--)
{
System.out.print(j+" ");
}
for(int j = i-1; j >= 1; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
}
}Number Pattern 6 :
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15
Solution :
class Demo6
{
public static void main(String args[])
{
for(int i = 1; i <= 5; i++)
for(int i = 1; i <= 5; i++)
{
int num = i;
for(int j = 1; j <=i; j++)
int num = i;
for(int j = 1; j <=i; j++)
{
System.out.print(num+" ");
num = num+5-j;
}
}
System.out.println();
}
}
}here another number pattern program in java which will help you in a java programming interviews.
Learn more : Top 10 Frequently asked java number pattern programs - Part 2.
Number Pattern 7 :
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Solution :
class Demo7
{
public static void main(String args[])
{
//upper half of the pattern
for(int i = 1; i <= 5; i++)
//upper half of the pattern
for(int i = 1; i <= 5; i++)
{
for(int j = 1; j <=i; j++)
for(int j = 1; j <=i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
//lower half of the pattern
}//lower half of the pattern
for(int i = 5-1; i >= 1; i--)
{
for(int j = 1; j <=i; j++)
for(int j = 1; j <=i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
}
Number Pattern 8 :
8 7 6 5 4 3 2 1
8 7 6 5 4 3 2
8 7 6 5 4 3
8 7 6 5 4
8 7 6 5
8 7
8
Solution :
class Demo8
{
public static void main(String args[])
{
for(int i = 1; i <= 8; i++)
for(int i = 1; i <= 8; i++)
{
for(int j = 8; j >=i; j--)
for(int j = 8; j >=i; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
}
}
Number Pattern 9 :
1 2 3 4 5 6 7 8
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
1 2 3 4 5 6 7 8
Solution :
Number Pattern 10 :
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
6 5 4 3 2 1
7 6 5 4 3 2 1
8 7 6 5 4 3 2 1
Solution :
}
Number Pattern 9 :
1 2 3 4 5 6 7 8
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
1 2 3 4 5 6 7 8
Solution :
class Demo9
{
public static void main(String args[])
{
for(int i = 8; i >= 1; i--)
for(int i = 8; i >= 1; i--)
{
for(int j = 1; j <=i; j++)
for(int j = 1; j <=i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
}
for(int i = 2; i <= 8; i++)
{
for(int j = 1; j <=i; j++)
for(int j = 1; j <=i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
}
Number Pattern 10 :
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
6 5 4 3 2 1
7 6 5 4 3 2 1
8 7 6 5 4 3 2 1
Solution :
class Demo10
{
public static void main(String args[])
{
for(int i = 1; i <= 8; i++)
for(int i = 1; i <= 8; i++)
{
for(int j = i; j >=1; j--)
for(int j = i; j >=1; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
}
}
Read More:
Star Pattern Programs in Java.
Alphabet Pattern Programs in Java.
Java Program to Check Leap Year or Not.
Java Program for Linear Search.
Java Program for Binary Search.
Java Program to Find Area of Square.
Here above all the java program to print of number are quite useful and all the above number pattern programs increase your logical capability.
}
Read More:
Star Pattern Programs in Java.
Alphabet Pattern Programs in Java.
Java Program to Check Leap Year or Not.
Java Program for Linear Search.
Java Program for Binary Search.
Java Program to Find Area of Square.
Here above all the java program to print of number are quite useful and all the above number pattern programs increase your logical capability.
what is the pattern of
ReplyDelete1
12
123
1234
12345
See first example in this article. If want to print without space you can just change in inner loop with System.out.print(j);.
Deleteplease give the program for
Delete1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5
public class Pattern4 {
Deletepublic static void main(String[] args) {
for (int i = 1; i <=5; i++) {
int k=i-1;
// For increasing order
for (int j = 1; j <=i; j++) {
k++;
System.out.print(k);
}
// For decreasing order
for (int l = k-1; l >= i; l--) {
System.out.print(l);
}
System.out.println();
}
}
}
for(int i = 1; i<=5; i++)
Delete{
for(int j = 1; j<=i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
int i, j;
Deletefor (i=1;i<=5;i++)
{
for(j=1;j <=i;j++)
{
S.o.p (j+" ");
}
S.p.println ();
}
}
}
int i, j;
Deletefor (i=1;i<=5;i++)
{
for(j=1;j <=i;j++)
{
S.o.p (j+" ");
}
S.p.println ();
}
}
}
I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts. Python Projects for Students Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account. Project Center in Chennai
Deletefor(int i=1;i<=n;i++){
Deleteint num=i;
for(int j=1;j<=i;j++){
System.out.print(num++ + " ");
}
int num1=num-1;
for(int j=1;j<i;j++){
System.out.print(--num1 + " ");
}
System.out.println();
}
plese give me program of
ReplyDelete1 2 1 2 1
2 1 2 1
2 1 2
1 2
1
package pattern;
Deleteclass Pattern
{
public static void main(String...args)
{
int a = 1,b=2,c=1;
for(int i = 1;i<=5;i++)
{
for(int j =5;j>=i;j--)
{
System.out.print(a);
c=a;
a=b;
b=c;
}
System.out.println();
}
}
}
thanx Sunny
Deletepattern for
ReplyDelete10
9 8
7 6 5
4 3 2 1
first value entered by user
int num=10;
Deletefor(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
System.out.print(num-- + " ");
}
System.out.println();
}
1
ReplyDelete2*2
3*3*3
4*4*4*4
4*4*4*4
3*3*3
2*2
1
please help me :(
1 1 2 3 4
ReplyDelete5 6 7 8 9
10 11 12 13 14
15 16 17 18 19
11
ReplyDelete2112
43211234
how to print this
what is the prog for this num:
ReplyDelete5
4 5
3 4 5
2 3 4 5
1 2 3 4 5
How to solve this pattern ?
ReplyDelete333
22
1
class Pattern
Delete{
public static void main(String[] ags)
{
for(int i=3;i>=1;i--)
{
for(int j=1;j<=i;j++)
{
System.out.print(i);
}
System.out.println();
}
}
}
how to solve this pattern:
ReplyDelete56789
5678
567
56
5
write code for
ReplyDelete54321
4321
321
21
1
for (int i=n;i>=1;i--){
Deletefor(int j=i;j>=1;j--){
System.out.print(j + " ");
}
System.out.println();
}
code for the pattern
ReplyDelete111112
222223
333334
444445
555556
code for the pattern
ReplyDelete111112
222223
333334
444445
555556
Pattern
ReplyDelete12345
23451
34512
45123
51234
please solve this pattern
ReplyDeleten is integer value
n = no of lines to be print
if n = 6
pattern will be
1111112
3222222
3333334
5444444
5555556
7666666
and so on
for(into i=0;i<=n;i++)
Delete{
if(i%2==0)
{
S.O.P(i+1);
}
for(into j=0;i<=n;i++)
{
S.O.P(i);
}
if(i%2==1)
{
S.O.P(i+1);
}
S.O.pln();
}
for(into i=0;i<=n;i++)
Delete{
if(i%2==0)
{
S.O.P(i+1);
}
for(into j=0;i<=n;i++)
{
S.O.P(i);
}
if(i%2==1)
{
S.O.P(i+1);
}
S.O.pln();
}
for(into i=0;i<=n;i++)
Delete{
if(i%2==0)
{
S.O.P(i+1);
}
for(into j=0;i<=n;i++)
{
S.O.P(i);
}
if(i%2==1)
{
S.O.P(i+1);
}
S.O.pln();
}
Sir how to get pattern like 1/2 +3/4+5/6+7/8
ReplyDeletePrint this pattern
ReplyDelete(((*)))
((*))
(*)
1
ReplyDelete3 5
7 9 11
13 15 17 19
plese share a code
int num=1;
Deletefor(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
System.out.print(num + " ");
num+=2;
}
System.out.println();
}
1
ReplyDelete12
1 3
1 4
12345
Explain how to write a condition
plz give the code for the pattern
ReplyDelete7
14 15
28 29 30 31
56 57 58 59 60 61 62 63
Plz give the code for the pattern
ReplyDelete2
13
468
5791
24682
will you please help me out with this code?
ReplyDelete1 2 3 4 5 4 3 2 1
2 3 4 5 4 3 2
3 4 5 4 3
4 5 4
5
How to print 1
ReplyDelete21
321
4321
ReplyDeleteHow to print
11 12 13
21 22 23
31 32 33
for(int i=1,i<=3,i++)
Delete{
for(int i=1,i<=3,i++)
{
S.o.p(i+""+j);
}
S.opln();
}
how to print?
ReplyDelete1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
1
ReplyDelete2 3
4 5 6
7 8
9
0
ReplyDelete01
023
0369
04816
solution plz
Please help me to print this pattern...
ReplyDelete1
2 2
0 0 0
1 1 1 1
2 2 2 2 2
0 0 0 0 0 0
Please help me to print this pattern...
ReplyDelete1
2 2
0 0 0
1 1 1 1
2 2 2 2 2
0 0 0 0 0 0
How to print
ReplyDelete*******
*****
***
*
***
*****
*******
Plz give a program for this pattern
ReplyDeleteAny one but process to all
I/p:2
112
233
I/p:4
3334
4555
I/p:7
6666667
7888888
Ple help me how to print this pattern.when n=4
ReplyDelete4321
321
21
1
Plz help me for this pattern
ReplyDelete1
2*2
3*3*3
4*4*4*4
4*4*4*4
3*3*3
2*2
1
how to solve this pattern
ReplyDelete1 2 3 4
1 2 2 3
1 2 3 2
1 2 3 4
Sir,plese help me with this problem
ReplyDelete1 2 3 4
1 2 2 3
1 2 3 2
1 2 3 4
1234
ReplyDelete432
21
1
hi please write this pattern code
4444
ReplyDelete444
44
4
Please answer ☺
How to print this pattern in java?
ReplyDelete12345
23456
34567
45678
56789
Pls, thanks^
javascodegeeks.net
ReplyDeleteHow to do this pattern:
ReplyDelete12345
51234
45123
34512
23451
3 2 *
ReplyDelete3 * 1
* 2 1
please help me to solve this
1234
ReplyDelete432
21
1
How can i solve it plz share
Help me to solve this pattern
ReplyDelete0
303
32023
3210123
1 2 4
ReplyDelete3 5 7
6 8 9
somebody help me coding this
1
ReplyDelete2 4
3 9 27
4 16 64 256
5 25 125 625 3125
Please write programme
Please tell code for this output..
ReplyDelete15 14 13 12 11
10 9 8. 7
6. 5. 4
3. 2
1