# Recursion

Process of a function that calls itself.

Must have an ending point, or it will go into an infinite loop.

```#include <stdio.h>

int factorial(unsigned int i)
{
printf("Recursion: %dn", i);
if(i <= 1)
{
return 1;
}
return i * factorial(i - 1);
}
int  main()
{
int i = 5;
printf("Factorial %d! = %dn", i, factorial(i));
return 0;
}```

Compile & run:

 Recursion: 5 Recursion: 4 Recursion: 3 Recursion: 2 Recursion: 1 Factorial 5! = 120
{"ft_lang_label":"__label__en","ft_lang_prob":0.5676492,"math_prob":0.9631807,"size":424,"snap":"2019-51-2020-05","text_gpt3_token_len":141,"char_repetition_ratio":0.20238096,"word_repetition_ratio":0.0,"special_character_ratio":0.3561321,"punctuation_ratio":0.23913044,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97385055,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-12-10T07:25:07Z\",\"WARC-Record-ID\":\"<urn:uuid:7161f6f3-1a32-4d09-92e7-9200012d44f7>\",\"Content-Length\":\"17133\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b36475b9-4d58-4680-8459-380e85326785>\",\"WARC-Concurrent-To\":\"<urn:uuid:a79fb4cc-4e8c-42f6-aa9a-e4fad51bcdc9>\",\"WARC-IP-Address\":\"178.62.56.128\",\"WARC-Target-URI\":\"https://c.tech-academy.co.uk/recursion/\",\"WARC-Payload-Digest\":\"sha1:SGORZAOABJE6JBWE6FNUTF6GHSX77EL2\",\"WARC-Block-Digest\":\"sha1:RLMHYCXWLEG7RWIDXCDXMYALJDZ6EEKK\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-51/CC-MAIN-2019-51_segments_1575540527010.70_warc_CC-MAIN-20191210070602-20191210094602-00130.warc.gz\"}"}