Decode the logic and print the pattern correspondent to given if n=3 then pattern will be 10203010011012**4050809***607
Answers
Answer:
Please find the attached file.
Explanation:
total Numbers=N*(N+1)
Every Number i appended with 0
and every row is appended with * with the multiple of 2
Answer:
import java.util.*;
class Main
{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int num = in.nextInt();
int star = 0, space, lterm = 1, rterm = num * num+1, i , j;
for(i = num; i> 0; i--)
{
for(space = 1; space <=star; space++)
{
System.out.print("*");
}
star +=2;
for(j = 1; j <= i; j++)
{
System.out.print(lterm+"0");
lterm++;
}
for(j = 1; j<= i; j++)
{
System.out.print(rterm);
if(j < i)
{
System.out.print("0");
}
rterm++;
}
rterm = rterm - (i -1) * 2 -1;
System.out.println();
}
}
}
Explanation: