We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9458c1e commit 25a2fa9Copy full SHA for 25a2fa9
src/recursion1.py
@@ -0,0 +1,29 @@
1
+#!/usr/bin/env python3
2
+
3
+##
4
+# Recursion
5
6
7
+def recursion(i):
8
+ """
9
+ This function demonstrates a simple recursive process. It prints the word "recursion" each time it is called,
10
+ and increments the value of the parameter `i`. The recursion stops when `i` reaches 5.
11
12
+ Parameters:
13
+ i (int): The current value that is incremented in each recursive call.
14
15
+ Returns:
16
+ None: This function does not return any value, it only prints output to the console.
17
18
+ print("recursion")
19
+ i += 1
20
+ if i == 5:
21
+ return
22
+ else:
23
+ recursion(i)
24
25
+# Initial call with value of i
26
+recursion(0)
27
28
29
0 commit comments