Mastery 21

Here is my code for the 21st mastery via GitHub: Mastery21

For the 21st mastery, you must use and show the use of recursion. As an example, i created a program to calculate the factorial of a inputted number. The way to compute the factorial without a loop is by recalling itself (recursion). 

In my code, The ‘Fact’ function contains the inputted number and a new ‘int’ named ‘factorial’ The code then will assign the value 1 to the ‘factorial’ int if the number inputted is 0. Otherwise, the ‘factorial’ int will be assigned to itself multiplied times the whole function again, except with the inputted number minus 1.

The recusion process has nothing to do with any outputting nor inoutting. The only thing needed to create repetition using recusion, is for one function to recall itself.

CC BY 4.0 Mastery 21 by Asa Puls is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.