Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Learn more about F# at http://fsharp.org
- // See the 'F# Tutorial' project for more help.
- let contFraction x =
- let xF = x |> Array.map(fun x -> float(x))
- let mutable sum = 0.0
- let n = xF.Length - 1
- sum <- xF.[n-1] + 1.0/xF.[n]
- for i=n-2 downto 0 do
- sum <- xF.[i] + 1.0/sum
- sum
- [<EntryPoint>]
- let main argv =
- printfn "Valoarea lui pi este:\t%A" System.Math.PI
- printfn "Valoarea fractiei este:\t%A" (contFraction [| 3; 7; 15 |])
- printfn "Valoarea fractiei este:\t%A" (contFraction [| 3; 7; 15; 1; 292; 1 |])
- 0 // return an integer exit code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement