Tap here to switch tabs
Problem
Submissions

Problem: Fraction to Recurring Decimal

Fraction to Recurring Decimal converts a numerator and denominator, which may be negative, into a string, showing its integer and fractional parts and enclosing any repeating digits in parentheses.

Statement

Given the two integer values of a fraction, numerator and denominator, implement a function that returns the fraction in string format. If the fractional part repeats, enclose the repeating part in parentheses.

Constraints:

  • denominator !=0!= 0
  • −105≤-10^{5} \leq numerator, denominator ≤105−1\leq 10^{5} - 1
⋮
Tap here to switch tabs
Problem
Submissions

Problem: Fraction to Recurring Decimal

Fraction to Recurring Decimal converts a numerator and denominator, which may be negative, into a string, showing its integer and fractional parts and enclosing any repeating digits in parentheses.

Statement

Given the two integer values of a fraction, numerator and denominator, implement a function that returns the fraction in string format. If the fractional part repeats, enclose the repeating part in parentheses.

Constraints:

  • denominator !=0!= 0
  • −105≤-10^{5} \leq numerator, denominator ≤105−1\leq 10^{5} - 1