Question

. Determine what is calculated for n = 5: unsigned int F(unsigned int n) { if(n...

. Determine what is calculated for n = 5:

unsigned int F(unsigned int n)

{

if(n == 0)

return 1;

return n ∗ F(n − 1);

}

Write an iterative version of the function in this problem

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Answer :
F(5) = 5 * 4 * 3 * 2 * 1 * 1 = 120

iterative version of the function is

unsigned int F(unsigned int n){
    unsigned int result = 1;
    while(n>0){
        result *= n;
        n--;
    }
    return result;
}
Add a comment
Know the answer?
Add Answer to:
. Determine what is calculated for n = 5: unsigned int F(unsigned int n) { if(n...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT