How can I calculate a factorial in C# using a library call?

后端 未结 6 1419
没有蜡笔的小新
没有蜡笔的小新 2021-01-05 10:29

I need to calculate the factorial of numbers up to around 100! in order to determine if a series of coin flip-style data is random, as per this Wikipedia entry on Bayesian p

6条回答
  •  半阙折子戏
    2021-01-05 10:56

    hello everybody according to this solution i have my own solution where i calculate factorial of array 1D elements. the code is `int[] array = new int[5] { 4,3,4,3,8 };

            int fac = 1;
    
            int[] facs = new int[array.Length+1];
    
            for (int i = 0; i < array.Length; i++)
            {
                for (int j = array[i]; j > 0; j--)
                {
                    fac *= j;
                }
                facs[i] = fac;
                textBox1.Text += facs[i].ToString() + " ";
                fac = 1;
            }`
    

    copy and paste the code above ^ in the button , it solves factorial of elements of array 1D. best regards.

提交回复
热议问题