Skip to content

Latest commit

 

History

History
42 lines (28 loc) · 903 Bytes

0166-fraction-to-recurring-decimal.adoc

File metadata and controls

42 lines (28 loc) · 903 Bytes

166. Fraction to Recurring Decimal

需要注意的是是:在 Map 中放的是被除数,而不是计算出来的位数digit。这样更方便处理!

Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.

If the fractional part is repeating, enclose the repeating part in parentheses.

Example 1:

Input: numerator = 1, denominator = 2
Output: "0.5"

Example 2:

Input: numerator = 2, denominator = 1
Output: "2"

Example 3:

Input: numerator = 2, denominator = 3
Output: "0.(6)"
link:{sourcedir}/_0166_FractionToRecurringDecimal.java[role=include]