Recursion: Process of repeating items in a self-similar way

Recursion is a word from mathematics and computer science.

It is used to define a thing, such as a function or a set. A recursive definition uses the thing it is defining as part of the definition.

Recursion: Description, Example, Uses
A visual form of recursion is the Droste effect. It leads to self-similar images.

Description

Usually, a recursive function refers to itself in some cases (or inputs), but not in every case. A function that referred to itself in every case would never terminate.

When a function refers to itself, it often uses a smaller input than the input it was given. In this way, it can solve a problem by first solving a simpler version of the problem.

Example

An example of a recursive function Recursion: Description, Example, Uses  is:

  • If Recursion: Description, Example, Uses  then return Recursion: Description, Example, Uses .
  • If Recursion: Description, Example, Uses  then return Recursion: Description, Example, Uses .

This function computes the factorial of a natural number. It works because Recursion: Description, Example, Uses  and Recursion: Description, Example, Uses .

The definition has two cases: a recursive case for Recursion: Description, Example, Uses , and a case for Recursion: Description, Example, Uses  that is not recursive. The case that is not recursive is called a "base case".

Uses

Recursion can be used to write computer programs. A program that uses recursion may be easier to write and understand than a program that does the same thing without recursion.

Recursion is used in mathematics to prove theorems. This method is called induction.

The idea of recursion can be seen in art and language. For example:

  • A fractal image contains smaller versions of itself.
  • In the rules of grammar, a sentence can be part of another sentence.

Easter Eggs

In the Google search engine, if you type up "recursion", it will say "Did you mean: Recursion", a reference to the meaning of recursion.

References


Tags:

Recursion DescriptionRecursion ExampleRecursion UsesRecursion Easter EggsRecursionComputer scienceDefinitionFunction (mathematics)MathematicsSet

🔥 Trending searches on Wiki Simple English:

HexadecimalApolloKendra LustPope Francis3 IdiotsNew York CityList of U.S. state capitalsJudaismGarry NewmanBallon d'OrLupang HinirangLouis ZamperiniSaturnList of cities in MexicoHuman penisBTS2 Girls 1 CupMahatma GandhiMotion Picture Association film rating systemPlanck constantAcademic grading in the PhilippinesSpanish languageEducationFarrah BrittanyMillennialsHecate0Jean-Claude Van DammeAriana GrandeTescoMulberryStanley Cup playoffsPopeyeBlack Widow (movie)199 (number)Room temperatureDhruv SharmaDavidLight bulbCanadaList of cities in PakistanPrincipality of SealandLitreFlag of GermanyKonami CodeBeyoncéSchrödinger's catRené AngélilList of elements by symbolTime in ChinaBenjamin FranklinCody RhodesDeath of Gloria RamirezUnited States presidential line of succession12-hour clockPetabyteMaslow's hierarchy of needsLiverpoolGaneshaQuiznosThe Valley (2024 TV series)Hubert Blaine Wolfeschlegelsteinhausenbergerdorff Sr.Kamala HarrisKareena KapoorUnited statesTeal (color)Squash (plant)RabbitAir fryerList of presidents of IndiaOblate spheroidMathematicsThe Legend of ZeldaCardinal directionPedro SánchezR. Budd Dwyer🡆 More