Continued fraction/Arithmetic/Construct from rational number: Difference between revisions
Continued fraction/Arithmetic/Construct from rational number (view source)
Revision as of 13:07, 2 February 2019
, 5 years ago→{{header|F_Sharp|F#}}: A version for larger numerators and denominators
(→{{header|F_Sharp|F#}}: A version for larger numerators and denominators) |
|||
Line 564:
[1; 2; 2; 2; 2; 2; 2; 2; 3; 6; 1; 2; 1; 12]
[1; 2; 2; 2; 2; 2; 2; 2; 2; 2; 6; 1; 2; 4; 1; 1; 2]</pre>
;A version for larger numerators and denominators.
<lang fsharp>
let rec rI2cf n d =
if d = 0I then []
else let q = n / d in (decimal)q :: (r2cf d (n - q * d))
</lang>
=={{header|Go}}==
|