CSharp examples for System:Math Number
Compute the factorial (n!) for p.
// Licensed under the Apache License, Version 2.0 (the "License"); using System;//from w w w. j a va 2s . c o m public class Main{ /// <summary> /// Compute the factorial (n!) for p. /// </summary> /// <param name="p">The number to compute the factorial for.</param> /// <returns>The factorial.</returns> public static double Factorial(int p) { double result = 1.0; for (int i = 1; i <= p; i++) { result *= (double)i; } return result; } }