Pattern Example-1
Pattern
----Pattern is----
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
package com.w3spoint;
import java.util.Scanner;
public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
scanner.close();
}
} |
package com.w3spoint; import java.util.Scanner;
public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5 |
Number of rows you want in this pattern?
5
----Pattern is----
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Pattern Example-2
Pattern
----Pattern is----
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
package com.w3spoint;
import java.util.Scanner;
public class Test
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print(i+" ");
}
System.out.println();
}
scanner.close();
}
} |
package com.w3spoint; import java.util.Scanner; public class Test
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print(i+" ");
}
System.out.println();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5 |
Number of rows you want in this pattern?
5
----Pattern is----
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Pattern Example-3
Pattern
----Pattern is----
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
package com.w3spoint;
import java.util.Scanner;
public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
// 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();
}
scanner.close();
}
} |
package com.w3spoint; import java.util.Scanner; public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
// 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();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
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 |
Number of rows you want in this pattern?
5
----Pattern is----
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
Pattern Example-4
Pattern
----Pattern is----
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
package com.w3spoint;
import java.util.Scanner;
public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = rows; i >= 1; i--)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
scanner.close();
}
} |
package com.w3spoint; import java.util.Scanner; public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = rows; i >= 1; i--)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1 |
Number of rows you want in this pattern?
5
----Pattern is----
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Pattern Example-5
Pattern
----Pattern is----
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5
package com.w3spoint;
import java.util.Scanner;
public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = rows; j >= i; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
scanner.close();
}
} |
package com.w3spoint; import java.util.Scanner; public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = rows; j >= i; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5 |
Number of rows you want in this pattern?
5
----Pattern is----
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5
Pattern Example-6
Pattern
----Pattern is----
5
5 4
5 4 3
5 4 3 2
5 4 3 2 1
package com.w3spoint;
import java.util.Scanner;
public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = rows; i >= 1; i--)
{
for (int j = rows; j >= i; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
scanner.close();
}
} |
package com.w3spoint; import java.util.Scanner; public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = rows; i >= 1; i--)
{
for (int j = rows; j >= i; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
5
5 4
5 4 3
5 4 3 2
5 4 3 2 1 |
Number of rows you want in this pattern?
5
----Pattern is----
5
5 4
5 4 3
5 4 3 2
5 4 3 2 1
Pattern Example-7
Pattern
----Pattern is----
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
package com.w3spoint;
import java.util.Scanner;
public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = rows; i >= 1; i--)
{
for (int j = i; j >= 1; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
scanner.close();
}
} |
package com.w3spoint; import java.util.Scanner; public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = rows; i >= 1; i--)
{
for (int j = i; j >= 1; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1 |
Number of rows you want in this pattern?
5
----Pattern is----
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
Pattern Example-8
Pattern
----Pattern is----
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
package com.w3spoint;
import java.util.Scanner;
public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = rows; i >= 1; i--)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
for (int i = 2; i <= rows; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
scanner.close();
}
} |
package com.w3spoint; import java.util.Scanner; public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = rows; i >= 1; i--)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
for (int i = 2; i <= rows; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
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 |
Number of rows you want in this pattern?
5
----Pattern is----
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
Pattern Example-9
Pattern
----Pattern is----
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
package com.w3spoint;
import java.util.Scanner;
public class Test
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; 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();
}
scanner.close();
}
} |
package com.w3spoint; import java.util.Scanner; public class Test
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; 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();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
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 |
Number of rows you want in this pattern?
5
----Pattern is----
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
Pattern Example-10
Pattern
----Pattern is----
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
package com.w3spoint;
import java.util.Scanner;
public class Test{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = i; j >= 1; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
scanner.close();
}
} |
package com.w3spoint; import java.util.Scanner; public class Test{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = i; j >= 1; j--)
{
System.out.print(j+" ");
}
System.out.println();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1 |
Number of rows you want in this pattern?
5
----Pattern is----
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
Pattern Example-11
Pattern
----Pattern is----
12345
2345
345
45
5
45
345
2345
12345
package com.w3spoint;
import java.util.Scanner;
public class Test{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j < i; j++)
{
System.out.print(" ");
}
for (int j = i; j <= rows; j++)
{
System.out.print(j);
}
System.out.println();
}
for (int i = rows-1; i >= 1; i--)
{
for (int j = 1; j < i; j++)
{
System.out.print(" ");
}
for (int j = i; j <= rows; j++)
{
System.out.print(j);
}
System.out.println();
}
scanner.close();
}
} |
package com.w3spoint; import java.util.Scanner; public class Test{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j < i; j++)
{
System.out.print(" ");
}
for (int j = i; j <= rows; j++)
{
System.out.print(j);
}
System.out.println();
}
for (int i = rows-1; i >= 1; i--)
{
for (int j = 1; j < i; j++)
{
System.out.print(" ");
}
for (int j = i; j <= rows; j++)
{
System.out.print(j);
}
System.out.println();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
12345
2345
345
45
5
45
345
2345
12345 |
Number of rows you want in this pattern?
5
----Pattern is----
12345
2345
345
45
5
45
345
2345
12345
Pattern Example-12
Pattern
----Pattern is----
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5
4 5
3 4 5
2 3 4 5
1 2 3 4 5
package com.w3spoint;
import java.util.Scanner;
public class Test{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j < i; j++)
{
System.out.print(" ");
}
for (int j = i; j <= rows; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
for (int i = rows-1; i >= 1; i--)
{
for (int j = 1; j < i; j++)
{
System.out.print(" ");
}
for (int j = i; j <= rows; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
scanner.close();
}
} |
package com.w3spoint; import java.util.Scanner; public class Test{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j < i; j++)
{
System.out.print(" ");
}
for (int j = i; j <= rows; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
for (int i = rows-1; i >= 1; i--)
{
for (int j = 1; j < i; j++)
{
System.out.print(" ");
}
for (int j = i; j <= rows; j++)
{
System.out.print(j+" ");
}
System.out.println();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5
4 5
3 4 5
2 3 4 5
1 2 3 4 5 |
Number of rows you want in this pattern?
5
----Pattern is----
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5
4 5
3 4 5
2 3 4 5
1 2 3 4 5
Pattern Example-13
Pattern
----Pattern is----
1
10
101
1010
10101
package com.w3spoint;
import java.util.Scanner;
public class Test{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= i; j++)
{
if(j%2 == 0)
{
System.out.print(0);
}
else
{
System.out.print(1);
}
}
System.out.println();
}
scanner.close();
}
} |
package com.w3spoint; import java.util.Scanner; public class Test{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= i; j++)
{
if(j%2 == 0)
{
System.out.print(0);
}
else
{
System.out.print(1);
}
}
System.out.println();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
1
10
101
1010
10101 |
Number of rows you want in this pattern?
5
----Pattern is----
1
10
101
1010
10101
Pattern Example-14
Pattern
----Pattern is----
10101
01010
10101
01010
10101
package com.w3spoint;
import java.util.Scanner;
public class Test{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
int num;
if(i%2 == 0)
{
num = 0;
for (int j = 1; j <= rows; j++)
{
System.out.print(num);
num = (num == 0)? 1 : 0;
}
}
else
{
num = 1;
for (int j = 1; j <= rows; j++)
{
System.out.print(num);
num = (num == 0)? 1 : 0;
}
}
System.out.println();
}
scanner.close();
}
} |
package com.w3spoint; import java.util.Scanner; public class Test{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
int num;
if(i%2 == 0)
{
num = 0;
for (int j = 1; j <= rows; j++)
{
System.out.print(num);
num = (num == 0)? 1 : 0;
}
}
else
{
num = 1;
for (int j = 1; j <= rows; j++)
{
System.out.print(num);
num = (num == 0)? 1 : 0;
}
}
System.out.println();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
10101
01010
10101
01010
10101 |
Number of rows you want in this pattern?
5
----Pattern is----
10101
01010
10101
01010
10101
Pattern Example-15
Pattern
----Pattern is----
11111
11122
11333
14444
55555
package com.w3spoint;
import java.util.Scanner;
public class Test{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= rows-i; j++)
{
System.out.print(1);
}
for (int j = 1; j <= i; j++)
{
System.out.print(i);
}
System.out.println();
}
scanner.close();
}
} |
package com.w3spoint;
import java.util.Scanner; public class Test{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
for (int j = 1; j <= rows-i; j++)
{
System.out.print(1);
}
for (int j = 1; j <= i; j++)
{
System.out.print(i);
}
System.out.println();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
11111
11122
11333
14444
55555 |
Number of rows you want in this pattern?
5
----Pattern is----
11111
11122
11333
14444
55555
Pattern Example-16
Pattern
----Pattern is----
00000
01000
00200
00030
00004
package com.w3spoint;
import java.util.Scanner;
public class Test{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < rows; j++)
{
if(i == j)
{
System.out.print(i);
}
else
{
System.out.print(0);
}
}
System.out.println();
}
scanner.close();
}
} |
package com.w3spoint;
import java.util.Scanner; public class Test{
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < rows; j++)
{
if(i == j)
{
System.out.print(i);
}
else
{
System.out.print(0);
}
}
System.out.println();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
00000
01000
00200
00030
00004 |
Number of rows you want in this pattern?
5
----Pattern is----
00000
01000
00200
00030
00004
Pattern Example-17
Pattern
----Pattern is----
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15
package com.w3spoint;
import java.util.Scanner;
public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
int num = i;
for (int j = 1; j <= i; j++)
{
System.out.print(num+" ");
num = num+rows-j;
}
System.out.println();
}
scanner.close();
}
} |
package com.w3spoint;
import java.util.Scanner; public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
int num = i;
for (int j = 1; j <= i; j++)
{
System.out.print(num+" ");
num = num+rows-j;
}
System.out.println();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15 |
Number of rows you want in this pattern?
5
----Pattern is----
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15
Pattern Example-18
Pattern
----Pattern is----
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15
package com.w3spoint;
import java.util.Scanner;
public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
int num = i;
for (int j = 1; j <= i; j++)
{
System.out.print(num+" ");
num = num+rows-j;
}
System.out.println();
}
scanner.close();
}
} |
package com.w3spoint;
import java.util.Scanner; public class Test{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Number of rows you want in this pattern?");
int rows = scanner.nextInt();
System.out.println("----Pattern is----");
for (int i = 1; i <= rows; i++)
{
int num = i;
for (int j = 1; j <= i; j++)
{
System.out.print(num+" ");
num = num+rows-j;
}
System.out.println();
}
scanner.close();
}
}
OutputNumber of rows you want in this pattern?
5
----Pattern is----
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15 |
Number of rows you want in this pattern?
5
----Pattern is----
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15