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

The anemia resulting from a deficiency of either vitamin B 12 (cobalamin) or folate is caused by a disruption in DNA synthesis of the blast cells in the bone ma
how did the reformation influence European exploration
Calculate the future value of ​$5 comma 000​, given that it will be held in the bank for 5 years and earn an annual interest rate of 6 percent. b. Recalculate p
Evaluate 3+(-4)-8-(-1)
Which equation represents a proportional relationship? y=2x2 y = 4x - 2 y= 1/2x +3 y=5x
What is the value of x in the figure?
La pluma está la mesa. La ventana está la puerta. La pizarra está los estudiantes. Las sillas están los escritorios. Los estudiantes llevan los libros la mochil
How does a solar system differ from a galaxy
Yuri has been given the task of evaluating how well his company, Comfy Shoes, Inc., has implemented its new line of slippers and how this implementation could b
Which expression is equivalent to Cube root of 125 x Superscript 6 Baseline y Superscript 15 Baseline z cubed?