Back
Close
  • 16

Learning Opportunities

This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.

Statement

 Goal

Convert any given recurring decimal to an irreducible fraction or an integer of equivalent amount.

A repeating decimal or recurring decimal is decimal representation of a number whose digits are periodic (repeating its values at regular intervals) and the infinitely repeated portion is not zero.
Input
Line 1 : A positive float x for the recurring decimal to be converted.
Output
Case 1 : A string with numerator, space, symbol /, space and denominator if the result is an irreducible fraction.
Case 2 : Otherwise, an integer .
Constraints
The number is always positive.
Example
Input
0.333333333333333
Output
1 / 3

A higher resolution is required to access the IDE