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

If work is constant, power increases as time increases. a. True b. False
ServletConfig defines a set of methods that a servlet uses tocommunicate with its servlet container. *True *False
Like terms can be added or subtracted true or false
Primary sensory afferents never cross the midline: a. True b. False
Many American institutions are are patterned after those in Europe . True or False .
I need help please.
If a line has a slope 2/5, what is the slope of any parallel line? Perpendicular line?
A digital computer has a memory unit with 24 bits per word. The instruction set consists of 150 different operations. All instructions have an operation code pa
. IDT stands for ______________________. ? interrupt descriptor table ? individual descriptor table ? inline data table ? interrupt descriptor table
which part of the bone is represented by the letter y