Question:For input N print 2N no. of lines same as following pattern
Assume input is 4 assume start number is 4
4
55
666
7777
7777
666
55
4
Note: i got only idea of Question, not the extact Question so modify According to your need.
Solution:
Assume input is 4 assume start number is 4
4
55
666
7777
7777
666
55
4
Note: i got only idea of Question, not the extact Question so modify According to your need.
Solution:
/********************* Happy Coding******************************/
package Amcat.pattern;
public class Number1 {
public static void patternGenerator(int n) {
int val = n;// start number
boolean flag = true;//used to inc. and dec. val
for (int i = 1; i <= n * 2; i++) {
for (int j = 1; i <= n && j <= i; j++)
{
System.out.print(val);
flag = true;
}
if (flag)
val++;
System.out.println();
if (!flag || i == n)
val--;
for (int j = i; i >= n && j < n * 2; j++) {
System.out.print(val);
flag = false;
}
}
}
public static void main(String[] args) {
patternGenerator(6);
}
}