factorial

Dec 9, 2013 at 5:56pm
how can write a function that calculate int fact(int n) output should be n!
Dec 9, 2013 at 6:13pm
closed account (18hRX9L8)
Did you start? Post your code up here if you did and we will help you fix it.
Last edited on Dec 9, 2013 at 6:13pm
Dec 9, 2013 at 6:32pm
i don't know how to write
Dec 9, 2013 at 6:47pm
Dec 9, 2013 at 8:23pm
closed account (18hRX9L8)
keskiverto wrote:
http://www.cplusplus.com/doc/tutorial/

For now, go through this tutorial to learn about how to program in C++. As you go through each lesson, you should complete exercises about that lesson so you can retain and try out the new information.

Note: You can't learn how to program this in a couple of weeks (or months), and if you are interested in learning more than the scope of this problem, it will take even years to get a full grasp of harder problems. Don't be discouraged though, learning how to program in C++ has many rewards.

Good luck,
Usandfriends
Last edited on Dec 9, 2013 at 8:25pm
Dec 9, 2013 at 8:27pm
http://www.cplusplus.com/doc/tutorial/functions/

Go to the very bottom they actually have a factorial example using recursion.

You could also use a while loop if you didn't want to have as much on the stack.
Topic archived. No new replies allowed.