Hello .. I would like to help with this exercise. I think it has to do with recursion .... but I do not have a clear idea.

A magic carpet of order n (0 ≤ n ≤ 5 ) and parameter k (0 ≤ k <9 ) `

and a 3^n× 3^n matrix , to binary values , defined inductively as follows:

• if n = 0 ( 1 × 1 matrix ) , then the only element of the array is 1 ;

• if n> 0 (matrix 3^n × 3^n ) , consider a subdivision of the matrix in 9

blocks of size 3^n- 1 × 3^n- 1 each. Consider numbered from 0 to 8

the blocks , in this way :

0 1 2

3 4 5

6 7 8

The block number j (0 ≤ j <9 ) `

and in turn

- A block of elements all equal to zero , if j = k ;

- A magic carpet of order n - 1 and parameter k , if j = k .

You want to create a Java program that data nek print a representation

text of a magic carpet of order n and parameter k .

Input format . The input `

and structured in the following way :

• a line containing two integers n and k , separated by a space.

Assume that nek satisfying constraints 0 ≤ n ≤ 5, 0 ≤ k <9 .

Output Format . You should print a magic carpet of order n parameter

k , according to the following code:

• the values equal to 0 are represented by the character ' . ' ;

• the values equal to 1 are represented by the character ' * ' .

The values in the same row are not separated by spaces. Each row of the matrix is

and

completed by the usual newline ' \ n ';

for example if I choose n = 2 and k = 4 this print

*********

*.**.**.*

*********

***...***

*.*...*.*

***...***

*********

*.**.**.*

*********

Thanks!