Need help understanding the factorial challenge

Hey may I ask for help here in this challenge cause I am a little bit weak in Math or numbers so I hope if I can get an explanation to understand and solve this challenge step by step

HI @Hamza-Noah !

I edited the title of your post to remove the challenge link.
Try to avoid placing links inside the title since we cannot click on them.
Also, creating descriptive titles will generate more responses to your post. :grinning:


For this challenge you can look into this Math is fun article on factorials
https://www.mathsisfun.com/numbers/factorial.html

But basically the way factorials work is that you are going to multiply all of the numbers from n to 1.

For example, here is the factorial of 5

5x4x3x2x1 = 120

Another way to visualize it would be this.

Instead of saying factorial of 5 is 5x4x3x2x1 couldn’t we rewrite it as 5 x factorial(4)

When you think about it, the factorial(4) is just 4x3x2x1.

Here is a way to break down the factorials

factorial(1) = 1
factorial(2) = 2x1 or 2 x factorial(1)
factorial(3) = 3x2x1 or 3 x factorial(2)
factorial(4) = 4x3x2x1 or 4 x factorial(3)
factorial(5) = 5x4x3x2x1 or 5 x factorial(4)

A popular way to solve this problem is to use recursion where you have a base case and recursive case.

Try to think of a good base case then think of the recursive case.

Hope that helps!

1 Like

Ok thanks for your help and sorry for replying lately may I ask one question where should I put the link of the challenge so everyone could be able to click them

If you look at your post, you will see that I have edited it to include the link inside the body.