Professional Documents
Culture Documents
Recursion
Throughout your computer science journey so far,
if(number == 1){
There are 2 parts to a recursive function:
return 1;
The first is the base case, which is critical for }
getting our recursive function to EXIT
What is recursion?
The next part is the recursive step. We can write the recursive step as:
This is where we get the function to
call itself. What do we know about
return number * factorial(number – 1).
factorials? That the factorial of a
number CAN be equal to the
number itself [multiplied by] the Our completed function is:
factorial of the previous number
int factorial (int number) {
if number == 1
return 1
return number * factorial(number – 1);
}
What is recursion?
Now let’s put a number into this function as Every time we call the recursive function, it
an example and see how we do, and see how gets pushed to the top of the stack until we
recursive functions operate hit a base case (number = 1). Then that value
gets returned and all the recursive calls get
Let’s try 4: popped off the stack one by one. 4 * 3 * 2 *
1 = 24, which IS 4!
Factorial (4) = 4 · Factorial (3)
This was a small intro to recursion!
3 · Factorial (2)
2 · Factorial (1)
Thanks Do you have any questions?
youremail@freepik.com
+91 620 421 838
yourwebsite.com
Vectors
● Desktop and smartphone app development
Resources
Did you like the resources on this template? Get them on our other websites.
Vectors
● Flat cms concept in blue shades
Instructions for use
If you have a free account, in order to use this template, you must credit Slidesgo by keeping the Thanks slide. Please
refer to the next slide to read the instructions for premium users.
For more information about editing slides, please read our FAQs or visit our blog:
https://slidesgo.com/faqs and https://slidesgo.com/slidesgo-school
Instructions for use (premium users)
As a Premium user, you can use this template without attributing Slidesgo or keeping the Thanks slide.
For more information about editing slides, please read our FAQs or visit our blog:
https://slidesgo.com/faqs and https://slidesgo.com/slidesgo-school
Fonts & colors used
This presentation has been made using the following fonts:
Alata
(https://fonts.google.com/specimen/Alata)
Archivo
(https://fonts.google.com/specimen/Archivo)
PHASE 1
Task 1
Task 2
PHASE 2
Task 1
Task 2
PHASE 1
Task 1
Task 2
...and our sets of editable icons
You can resize these icons without losing quality.
You can change the stroke and fill color; just select the icon and click on the paint bucket/pen.
In Google Slides, you can also use Flaticon’s extension, allowing you to customize and add even more icons.
Educational Icons Medical Icons
Business Icons Teamwork Icons
Help & Support Icons Avatar Icons
Creative Process Icons Performing Arts Icons
Nature Icons
SEO & Marketing Icons