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

Q4 please help thanks
Thirty students equally divided into teams
match them together to correct answer
Identify the following italicized word as a gerund, participle, or infinitive. Daily ''jogging'' is a good way to build one's strength and stamina. type of
demand is the ___ and _____ to buy a given good or service
who develope a plan to fight the depression
Identify the term for “the sex cell that is produced by the testes and that is needed to fertilize an egg”
A B C D really need this right
which of the following could be a rational number? A. the sum of two irrational numbers B. the product of two irrational number C. the sum of a rational number
Heo started to solve the quadratic equation (x + 2)2 – 9 = –5. He added 9 to both sides and the resulting equation was (x + 2)2 = 4. Next, he took the square ro