Continued fraction/Arithmetic/Construct from rational number: Difference between revisions
Content added Content deleted
(Added Kotlin) |
m (→{{header|Haskell}}: hlint, hindent, added output section) |
||
Line 475: | Line 475: | ||
real2cf :: (RealFrac a, Integral b) => a -> [b] |
real2cf :: (RealFrac a, Integral b) => a -> [b] |
||
real2cf x = |
real2cf x = |
||
⚫ | |||
⚫ | |||
in i : |
|||
⚫ | |||
if f == 0 |
|||
then [] |
|||
⚫ | |||
main :: IO () |
main :: IO () |
||
main = |
main = |
||
mapM_ |
|||
⚫ | |||
print |
|||
⚫ | |||
⚫ | |||
, take 20 $ real2cf (sqrt 2) |
|||
]</lang> |
|||
{{Out}} |
|||
<pre>[1,5,2] |
|||
⚫ | |||
=={{header|J}}== |
=={{header|J}}== |