Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
factorial calculation of any number
Posted
Comments
Sandeep Mewara 6-Mar-11 2:16am    
:doh:

No effort at all!
Toli Cuturicu 6-Mar-11 16:38pm    
This cannot be done.
It is impossible to calculate and even display the factorial of an arbitraly large number!

1 solution

Should be simple loop. Why didn't google?

C#
public int fact(int x)
{
    int fact=1;
    int i=1;
    while (i<=x)
    {
       fact = fact * i;
       i++;
    }
    return fact;
}
 
Share this answer
 
Comments
Sandeep Mewara 6-Mar-11 2:17am    
Hey, Good you helped him. :thumbs up:

But lets try to refrain answering such people & questions. What say?

Totally zero effort that too sounds like a homework!
Sergey Alexandrovich Kryukov 6-Mar-11 3:29am    
Agree, in such cases I write the notation on how bad is cheating.
--SA
Sandeep Mewara 6-Mar-11 3:30am    
:)
Toli Cuturicu 6-Mar-11 16:39pm    
This only works for very small numbers.
Let's calculate the factorial of uint.MaxValue instead!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900