Function Repository Resource:

RepeatingDecimalToRational

Source Notebook

Find a rational number equivalent to a real number with repeating digits

Contributed by: Wolfram|Alpha Math Team

ResourceFunction["RepeatingDecimalToRational"][x,n]

returns a rational number that approximates x, assuming the last n digits of x repeat infinitely.

ResourceFunction["RepeatingDecimalToRational"][x,{a,b,c,}]

returns a rational number that approximates x with the repeating digits {a,b,c,} appended.

Details and Options

ResourceFunction["RepeatingDecimalToRational"] expects a real number as its first argument.

Examples

Basic Examples (3) 

Find a fractional representation for 0.333:

In[1]:=
ResourceFunction["RepeatingDecimalToRational"][0.3, 1]
Out[1]=

Check the fractional representation of 1/7:

In[2]:=
ResourceFunction["RepeatingDecimalToRational"][0.142857, 6] == 1/7
Out[2]=

Specify which digits are repeating:

In[3]:=
ResourceFunction["RepeatingDecimalToRational"][0.1523, {8, 3}]
Out[3]=

Numericize that:

In[4]:=
% // N[#, 10] &
Out[4]=

Publisher

Wolfram|Alpha Math Team

Version History

  • 2.0.0 – 23 March 2023
  • 1.0.0 – 20 April 2020

License Information