ayushajayverulkar
ayushajayverulkar ayushajayverulkar
  • 20-08-2021
  • Computers and Technology
contestada

Topic:

Recursion. Use recursion to display the pattern given above. No loops allowed.

See the picture for the pattern​

Topic Recursion Use recursion to display the pattern given above No loops allowed See the picture for the pattern class=

Respuesta :

tonb
tonb tonb
  • 20-08-2021

Answer:

const SIZE=8

function print(n, s) {

 if (n > 0) {

   process.stdout.write(s);

   print(n-1, s);

 }

}

function main(n=1) {

 if (n<=SIZE) {

   print(SIZE-n, "  ");

   print(n, "* ");

   process.stdout.write("\n");

   main(n+1);

 }

}

main();

Explanation:

Here is a solution in javascript. Note that it uses recursion multiple times to avoid loops.

Answer Link

Otras preguntas

Which sentence does not contain any punctuation errors? A. Would you agree that Chicago Illinois, and Los Angeles California, are expensive places to live? B. W
Josh works for MooMoo Milkshakes. The company wants to know what milkshake flavor is the most popular. Today, he surveyed every third female customer on their f
An equality of two ratios is called a
which southern colony was founded as a refuge for Catholics and who founded it PLEASE ANSWER NOW!!!!!!!!!!
what is 5n=25 equal too I need a lot of help
what does euphoria mean?
Who built Fort Ross and why?
Who is louise Clapp?
why can a square never be a trapezoid
Which of the following statements best describes the graph of x + y = 5? (4 points) 1. It is a line joining the points whose x and y-coordinates add up to 10.