You know what a factorial is I hope?
Then you know you need multiplication to calculate it.
The simplest program would use a for loop, something like
long fact = 1;
// request is the number of which the factorial is requested
for (int i=1; i<=request; fact *= i++);
I'm not sure why you'd want to use overloaded operators, I guess you have to make a class Factorial.
If that's so the operator seems simple, with a body like "return f*i;" where f is a class member and i the parameter to the operator.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337