Generation

generate functionWed, 01 May 2024

Write a program that will calculate the factorial of the following (Do not perform this using Loop): a) 6 b) 5 c) 4 d 3 perform above code with easy logic without any condition and loop

factorial(int n) { if (n == 0) return 1; else return n * factorial(n - 1); } A: The problem is that you are not returning anything from the recursive call. You need to return the result of the recursive call: int factorial(int n) { if (n == 0) return 1; else

Questions about programming?Chat with your personal AI assistant