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
Countless7Echos:
I don't know just no sketch doodle day :p finished a video already so I'm pretty
Ferrari:
Depression Hi, it's me, Jordan (ferrari). It's supposed to be the Fourth of July but I feel kinda depressed and mad at myself for no reason.
Countless7Echos:
mmm I forgot to post but hey first time trying out hyperpop art :3 super fun TW:
RAVEN69:
The hole You can't fix the hole in my heart. It's permanent. It's been broken to many times and I love it every time.
4 hours ago
9 Replies
2 Medals
6 hours ago
12 Replies
1 Medal
1 day ago
9 Replies
5 Medals
2 days ago
0 Replies
0 Medals