Ask
your own question, for FREE!
Mathematics
10 Online
What does the following algorithm return? f(n){ if (n < 2) return 1 else return f(n – 1) * n:
Still Need Help?
Join the QuestionCove community and study together with friends!
Would it not depend on the value of 'n'?
This looks like the recursive algorithm for finding the factorial of n.
Let's assume 'n' is 3, It would return 3X2 = 6. How is that the factorial?
3*2*1=6
well it is in that case, i just realized but what if it was 4?
Still Need Help?
Join the QuestionCove community and study together with friends!
4*3*2*1=24
It just multiplies 4X3, not 2 and 1.
f(n-1) * n
it multiplies \(f(3)*4 =6*4=24\) since \(f(3)=6\)
looks like the recursive definition of factorial right?
Still Need Help?
Join the QuestionCove community and study together with friends!
so n!
exactly.
yes, that is it. multiply n - 1 th number by n
Ok thanks
Alright. I'll take your word for it.
Can't find your answer?
Make a FREE account and ask your own questions, OR help others and earn volunteer hours!
Join our real-time social learning platform and learn together with your friends!
Join our real-time social learning platform and learn together with your friends!
Latest Questions
addison123456:
I have a quote that will hit hard but someone needs to tell me what it means. "I am not crying over you.
breiadabrattzz:
Do anyone know how to use Canva and do like personal photos for UNT Denton and in
xXAikoXx:
Can peanut oil cause allergic reactions to someone with a peanut allergy?
gelphielvr:
How does a person's community (where they are from, who they surround themselves with, their u201cpeopleu201d, etc.
Nina001:
I need ideas on what religion I should do on my history project and some good facts.
gelphielvr:
Based on the 1920s identify new behaviors, dress, and attitudes of women in Ameri
gelphielvr:
How did buying on credit create an economic boom in the 1920s?
gelphielvr:
Where are the different types of valance electrons located on the periodic table?
13 hours ago
13 Replies
0 Medals
13 hours ago
31 Replies
3 Medals
12 hours ago
12 Replies
0 Medals
19 hours ago
2 Replies
1 Medal
23 hours ago
4 Replies
0 Medals
1 day ago
12 Replies
1 Medal
21 hours ago
6 Replies
1 Medal
2 days ago
3 Replies
3 Medals