Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Fsharp implementation of leibniz algo #108

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ collect-data:
BUILD +cpp-clang
BUILD +crystal
BUILD +cs
BUILD +fs
BUILD +d
BUILD +d-ldc
BUILD +elixir
Expand Down
10 changes: 10 additions & 0 deletions src/fs/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
open System
open System.IO
let rounds = File.ReadAllText("rounds.txt", System.Text.Encoding.UTF8) |> int
let pi =
let rec loop (i:int) (rounds:int) (pi:double) =
if i >= rounds + 2 then pi
else
loop (i + 1) rounds (-(pi + (1.0 / (double (2 * i - 1)))))
-4.0 * (loop 0 rounds 1.0)
printfn "%A" pi
10 changes: 10 additions & 0 deletions src/fs/leibniz.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>

</Project>