## Day 9 - Recursion

November 08, 2017

Objective

Today, we’re learning and practicing an algorithmic concept called Recursion. Check out the Tutorial tab for learning materials and an instructional video!

Recursive Method for Calculating Factorial

Write a factorial function that takes a positive integer, as a parameter and prints the result of ( factorial).

Note: If you fail to use recursion or fail to name your recursive function factorial or Factorial, you will get a score of 0.

Input Format

A single integer, $N$ (the argument to pass to factorial).

Constraints

$\cdot$ Your submission must contain a recursive function named factorial.

Output Format

Print a single integer denoting .

Sample Input

3

Sample Output

6

Explanation

Consider the following steps:

From steps 2 and 3, we can say $factorial(2)=2 \times 1 = 2$; then when we apply the value from $factorial(2)$ to step 1, we get $factorial(3)=3 \times 2 \times 1 = 6$. Thus, we print 6 as our answer.