Menu
Coddy logo textTech

Factorial

Lesson 5 of 15 in Coddy's Recursion Challenges - Master The Recursive Thinking course.

challenge icon

Challenge

Easy

Write a function named fact that gets an integer num and returns the factorial of num.

Factorial of n is the product of all the numbers 1 to n

Examples,

  • fact(4)  ->  24 = 1 *  2 * 3 * 4
  • fact(6)  ->  720 = 1 * 2 * 3 * 4 * 5 * 6

Factorial of n is written, in math, n!

The factorial of 0 is 1.

Try it yourself

int fact(int num) {
    // Write code here
}

All lessons in Recursion Challenges - Master The Recursive Thinking