From ca4812964e78502a9e70972ba4eb72384e851e2e Mon Sep 17 00:00:00 2001 From: Matt <36519879+MattyBear@users.noreply.github.com> Date: Tue, 23 Oct 2018 11:40:57 -0400 Subject: [PATCH] Added some info on recursion (#19814) May be important info for some --- guide/english/c/functions/index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/guide/english/c/functions/index.md b/guide/english/c/functions/index.md index 49ad415db4..0afed55a84 100644 --- a/guide/english/c/functions/index.md +++ b/guide/english/c/functions/index.md @@ -105,6 +105,13 @@ int factorial (int n) return (n * factorial (n -1)); } ``` + +The recursion continues until some condition is met to prevent it. +To prevent infinite recursion, an if...else statement or similar approach can be used where one branch makes the recursive call and the other doesn't. + +Recursion makes program more elegant and clean. All algorithms can be defined recursively, which makes it easier to visualize and prove. +If the speed of the program is important then you may not want to use recursion as it uses more memory and can slow the program down. + # Before you go on... ## A review