I am trying to solve the challenge with a for cycle and for this reason I tried with the code I posted above. In my opinion it is supposed to be iterating until the variable “i” which starts from 1 reaches the number “num” but in fact it ends as you said at 5. So, can you explain to me where my logic goes wrong and how can I rewrite the code so that it does just that?
As I told you, the function stops as soon as it reached a return,
You need your for loop to end, so the return call must be after the loop (generally speaking, never put a return call in a loop).
Try to put the return call after the loop.
If you still have struggle with it, I stay around with more hints
i can help you .you need to initialise the bottom layer of recursion which is given their .The principal of recursion distributes the work among several layers but the actual work is done at downmost layer .That means at the “cell - level”. so mention what should your code do when you have num= num * factorialize(num - 1)
because when you are finding factorial of 5 code will work like
5 = 5 * factorialize(5 - 1) and its calling “factorialize” function again. now think what you code should produce when factorialize (1 - 1) will occur .So you need to define what should be the function value when num = 0. By defining that you have defined the last layer of recursion and now your code will run and it will give you result as 54321=?.
remember that this problem is of “Recursion” . In recursion function call itself again in function definition.