# Java Program to Print Exponentially Increasing Number Pattern

## Printing Exponentially Increasing Number Pattern

In the previous article, we have discussed Java Program to Print Inverted Right-Angled Triangle with Decreasing Number Pattern

In this article we will see exponentially increasing number pattern.

For example :

Enter the number of lines: 5

1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Are you wondering how to seek help from subject matter experts and learn the Java language? Go with these Basic Java Programming Examples and try to code all of them on your own then check with the exact code provided by expert programmers.

APPROACH:

• Enter how many lines you have to print and store it in variable noOflines.
• Using Scanner class Take inputs from User.
• Take a for loop to iterate the Row.
• Take an inner for loop to print the values in each row.

### Java to Print Exponentially Increasing Number Pattern

// Java program for print the
// given numeric pattern in exponentially order
import java.util.*;
class Main
{
public static void main(String args[])
{
//Taking input from USER
System.out.print("Enter the number: ");
int num = read.nextInt();
System.out.print("Enter the number of lines: ");
int noOflines = read.nextInt();

{
int n = num, num2 = 0,
x = 1, limit = 1;

// Number of rows to  be printed
for (int row = 0;
row < noOflines; row++)
{

// Number of elements to  be printed

for (int col = 0; col < limit; col++)
{
if (col == 0)
num2 = num;

// Print all the element
System.out.print(num2++ + " ");
}

num *= 2;
limit = num / n;
System.out.println();
}
}
}
}

Output:

Enter the number: 1
Enter the number of lines: 5

1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

### C++ to Print Exponentially Increasing Number Pattern

// Java program for print the
// given numeric pattern in exponentially order.
#include <bits/stdc++.h>

using namespace std;

int main()
{

int num = 1;
int noOflines = 5;

int n = num, num2, x = 1, limit = 1;

// Number  of rows to be printed
for (int row = 0; row < noOflines; row++) {

// Number of elements to be printed in each row
for (int col = 0; col < limit; col++) {
if (col == 0)
num2 = num;

// Print all the element
cout << num2++ << " ";
}
num *= 2;
limit = num / n;
cout << endl;
}

return 0;
}

Output:

1
2 3
4 5 6 7
8 9 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Are you seeking professional help for coding in the Java programming language? The tutorial of Java Programming Examples for beginners and experts will strongly improve your coding skills then you can program for any logic in Java.

Related Java Number Pattern Programs: