相关疑难解决方法(0)

如何知道分数中的重复小数?

我已经知道一个分数是重复小数.这是功能.

public bool IsRepeatingDecimal
{
    get
    {
        if (Numerator % Denominator == 0)
            return false;

        var primes = MathAlgorithms.Primes(Denominator);

        foreach (int n in primes)
        {
            if (n != 2 && n != 5)
                return true;
        }

        return false;
    }
}
Run Code Online (Sandbox Code Playgroud)

现在,我正试图获得重复的数字.我正在查看这个网站:http://en.wikipedia.org/wiki/Repeating_decimal

public decimal RepeatingDecimal()
{
    if (!IsRepeatingDecimal) throw new InvalidOperationException("The fraction is not producing repeating decimals");

    int digitsToTake;
    switch (Denominator)
    {
        case 3:
        case 9: digitsToTake = 1; break;
        case 11: digitsToTake = 2; break;
        case 13: …
Run Code Online (Sandbox Code Playgroud)

c# algorithm class

12
推荐指数
2
解决办法
8230
查看次数

标签 统计

algorithm ×1

c# ×1

class ×1