6 kyu

Group Repeating Fractions

179 of 362joh_pot

Description:

Write

function repeatingFractions(numerator, denominator)
function repeating_fractions(numerator, denominator)
function repeating_fractions(numerator, denominator)

that given two numbers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part has repeated digits, replace those digits with a single digit in parentheses.

For example:

repeatingFractions(1,1) === '1'
repeatingFractions(1,3) === '0.(3)'
repeatingFractions(2,888) === '0.(0)(2)5(2)5(2)5(2)5(2)5(2)'
repeating_fractions(1,1) === '1'
repeating_fractions(1,3) === '0.(3)'
repeating_fractions(2,888) === '0.(0)(2)5(2)5(2)5(2)5(2)5(2)'
repeating_fractions(1,1) === '1'
repeating_fractions(1,3) === '0.(3)'
repeating_fractions(2,888) === '0.(0)(2)5(2)5(2)5(2)5(2)5(2)'
Strings
Fundamentals

Similar Kata:

Stats:

CreatedOct 6, 2015
PublishedOct 6, 2015
Warriors Trained872
Total Skips55
Total Code Submissions1560
Total Times Completed362
JavaScript Completions179
Ruby Completions49
Python Completions167
Total Stars14
% of votes with a positive feedback rating84% of 91
Total "Very Satisfied" Votes72
Total "Somewhat Satisfied" Votes9
Total "Not Satisfied" Votes10
Ad
Contributors
  • joh_pot Avatar
  • GiacomoSorbi Avatar
  • bidouille Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad