Answer to Question #247115 in C++ for ghhuh

Question #247115

1 Write a function in C++ to find the factorial of a number (using while loop).


1
Expert's answer
2021-10-05T13:23:23-0400
int factorial(int n) {
    int x = 1;
    int i = 2;
    while (i <= n) {
        x *= i;
        i++;
    }
    return x;
}

Sorry, my bad, mistake choosing loop)


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS