WordNet-Online
Free dictionary and thesaurus of English. Definitions, synonyms, antonyms and more...
Hint: double-click any word to get it searched!

Google
 

recursive function

 

Definitions from the Web

Recursive Function

A recursive function is a programming construct that calls itself within its own definition. It is usually used when a problem can be broken down into smaller sub-problems of the same nature.

Sense 1: Programming

Definition

In the context of programming, a recursive function refers to a function that calls itself until a specific condition is met. This type of function is often utilized to solve complex problems by dividing them into simpler sub-problems.

Usage

Example 1: The factorial of a non-negative integer n can be calculated using a recursive function.

function factorial(n) {
    if (n === 0) {
        return 1;
    } else {
        return n * factorial(n - 1);
    }
}

console.log(factorial(5)); // Output: 120

Example 2: Recursive functions are commonly employed to traverse and manipulate data structures like linked lists, trees, and graphs.

function traverseList(node) {
    console.log(node.data);
    if (node.next !== null) {
        traverseList(node.next);
    }
}

Related Products

recurring recurring cost recurring decimal recurringly recurse recursion recursive recursive definition recursive function recursive routine recursively recurso recursos recurvate recurve recurved recurvirostra

Sponsored (shop thru our affiliate link to help maintain this site):

WordNet-Online
Home | Free dictionary software | Copyright notice | Contact us | WordNet dictionary | Automotive thesaurus