środa, 6 sierpnia 2014

C Factorial large numbers approximate method





#include <iostream>
#include <math.h>

double factorial(int n)
{
    double result=1;

    if(n>30)
        result=pow(n/M_E,n)*sqrt(2*M_PI*n);        //FOR BIG NUMBERS

    else
        for(int i=1;i<=n;i++)                                       //FOR SMALL NUMBERS
        {
            result*=i;
        }
        return result;

}

Returning

Hi,
Some information.
 I begin to publish again. I have two emails, so posts are published by two names(both mine).
 I write in English, because most people who read my blog don`t speak Polish and translaction isn`t good for program code.

If you find fault but you have problem with my code or You want my help with something problem write to me.

I`m sorry for my English , please corect mi if You can  :)