Advertisement
Guest User

Untitled

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