Jump to content

Continued fraction/Arithmetic/Construct from rational number: Difference between revisions

→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details
m (→‎{{header|Haskell}}: hlint, hindent, added output section)
(→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details)
Line 696:
// compile with -Xcoroutines=enable flag from command line
 
import kotlin.coroutines.experimental.*buildSequence
 
fun r2cf(frac: Pair<Int, Int>) =
buildSequence {
var num = frac.first
Line 723:
}
val root2 = arrayOf(14142 to 10000, 141421 to 100000,
1414214 to 1000000, 14142136 to 10000000)
println("\nSqrt(2) ->")
for (frac in root2) {
Line 729:
iterate(r2cf(frac))
}
varval pi = arrayOf(31 to 10, 314 to 100, 3142 to 1000, 31428 to 10000,
314285 to 100000, 3142857 to 1000000,
31428571 to 10000000, 314285714 to 100000000)
Cookies help us deliver our services. By using our services, you agree to our use of cookies.