Exemplo n.º 1
0
 public EgyptianFractions Calculate()
 {
     if (numerator == 0)
     {
         return(this);
     }
     AddFraction(NextFraction);
     if (Value < (double)numerator / denominator)
     {
         var remaining = new EgyptianFractions(RemainingNumerator, RemainingDenominator);
         remaining.Calculate();
         Fractions.AddRange(remaining.Fractions);
     }
     return(this);
 }
Exemplo n.º 2
0
    public static string Decompose(string nrStr, string drStr)
    {
        var fractions = new EgyptianFractions(nrStr, drStr);

        return(fractions.Calculate().ToString());
    }