answersLogoWhite

0

The two properties of a recursive object or routine, F, are:

  1. F must have a simple base case (or have simple base cases).
  2. F must have a set of rules that reduces all other cases towards the base case.

A classic example of recursion is the definition of a factorial.

Fact(0) = 1

Fact(n) = n * Fact(n - 1)

For computer science, writing this function in JavaScript would look like:

function factorial(n) {

if (n === 0) {

return 1;

} else {

return n * factorial(n - 1);

}

}

User Avatar

Wiki User

11y ago

What else can I help you with?