CSharp examples for Data Structure Algorithm:Factorial
Create and exercise a factorial method that has no error checks at all.
using System;//from w w w.ja v a 2s .c o m public static class MyMathFunctions { public static double Factorial(double value) { double factorial = 1.0; do { factorial *= value; value -= 1.0; } while(value > 1); return factorial; } } public class Program { public static void Main(string[] args) { for (int i = 6; i > -6; i--) { Console.WriteLine("i = {0}, factorial = {1}", i, MyMathFunctions.Factorial(i)); } } }