■ 팩토리얼 구하기 예제

----------------------------------------------------------------------------------------------------

using System;

 

double value = GetFactorial(5);

 

Console.WriteLine(value);

----------------------------------------------------------------------------------------------------

 

■ 팩토리얼 구하기

----------------------------------------------------------------------------------------------------

using System;

 

#region 팩토리얼 구하기 - GetFactorial(value)

 

/// <summary>

/// 팩토리얼 구하기

/// </summary>

/// <param name="value"></param>

/// <returns>팩토리얼</returns>

public double GetFactorial(int value)

{

    double factorial;

 

    for(factorial = 1; value > 0; value--)

    {

        factorial *= Convert.ToDouble(value);

    }

 

    return factorial;

}

 

#endregion

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요