Help with an algorithm for converting decimals to fractions
08-27-2014, 10:32 PM (This post was last modified: 08-28-2014 03:29 AM by Thomas Klemm.)
Post: #3
 Thomas Klemm Senior Member Posts: 1,447 Joined: Dec 2013
RE: Help with an algorithm for converting decimals to fractions
Let's assume you wan't to calculate the common fraction of the continued fraction of $$\pi$$ = [3; 7, 15, 1, 292, ...].
Then you write this sequence down and below a matrix of 0 and 1:
Code:
  3  7  15    1  292  ... 0 1 1 0
Now you multiply each entry with the corresponding value of the sequence, add the value of the left and write it to the right:
Code:
  3  7  15    1  292  ... 0 1  3  22  333  355  ... 1 0  1   7  106  113  ...
Thus the approximations of $$\pi$$ are $$\frac{3}{1}, \frac{22}{7}, \frac{333}{106}, \frac{355}{113}, \dots$$

Cheers
Thomas
 « Next Oldest | Next Newest »

 Messages In This Thread Help with an algorithm for converting decimals to fractions - Namir - 08-27-2014, 08:55 PM RE: Help with an algorithm for converting decimals to fractions - Paul Dale - 08-27-2014, 10:12 PM RE: Help with an algorithm for converting decimals to fractions - Thomas Klemm - 08-27-2014 10:32 PM RE: Help with an algorithm for converting decimals to fractions - CosmicTruth - 08-28-2014, 12:51 AM RE: Help with an algorithm for converting decimals to fractions - Joe Horn - 08-28-2014, 06:03 AM RE: Help with an algorithm for converting decimals to fractions - Joe Horn - 08-28-2014, 06:48 AM

User(s) browsing this thread: 1 Guest(s)