You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Understand what the interviewer is asking for by using test cases and questions about the problem.
Will n always be a positive integer?
Yes.
P-lan
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Create a function that calculates the factorial of a positive integer n.
1) Create and initialize a variable to store the result
2) For each number from 1 to n, multiply the result by that number
3) Return the result variable
⚠️ Common Mistakes
Make sure your result variable is correctly initialized! What is the smallest possible result for our factorial function?