The Computer Language
Benchmarks Game

pidigits F# .NET Core program

source code

// The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org/
//
// contributed by Valentin Kraevskiy
// fixed by Joel Mueller

#light
    
let id = 1I, 0I, 0I, 1I

let comp (q, r, s, t) (u, v, x) =
    (q * u, q * v + r * x, s * u, s * v + t * x)

let div x y = 
    let rec next w n =        
        if w > x then n else next (w + y) (n + 1I)
    next y 0I
let extr (q, r, s, t) x = div (q * x + r) (s * x + t)   
    
let next z = extr z 3I
let safe z = (=) (extr z 4I)
let prod (u, v, w, x) n =
    let neg = -10I * n
    (10I * u + neg * w, 10I * v + neg * x, w, x)

let digits = 
    let z = ref id    
    let lfts = 
        let n = ref 0I
        fun () -> n := !n + 1I
                  !n, 4I * !n + 2I, 2I * !n + 1I
    let rec digits () =
            let y = next !z 
            if safe !z y 
                then z := (prod !z y)
                     y
                else z := (comp !z <| lfts ())
                     digits ()
    digits

let rec loop n s total = 
    if total = 0 
        then for _ in 1 .. n do printf " "
             printf ("\t:%i\n") (s + 10 - n)
        else if n = 0 
            then printf "\t:%i\n" <| s + 10
                 loop 10 (s + 10) total
            else printf "%i" <| int (digits ()) 
                 loop (n - 1) s (total - 1)

loop 10 0 <| try int (System.Environment.GetCommandLineArgs().[1]) with _ -> 27

 
    

notes, command-line, and program output

NOTES:
64-bit Ubuntu quad core
2.0.0-preview1-005977
"System.GC.Server": true


Thu, 08 Jun 2017 21:59:10 GMT

MAKE:
cp pidigits.fsharpcore Program.fs
cp Include/fsharpcore/tmp.fsproj .
cp Include/fsharpcore/runtimeconfig.template.json .
mkdir obj
cp Include/fsharpcore/project.assets.json ./obj
cp Include/fsharpcore/tmp.fsproj.nuget.g.props ./obj
cp Include/fsharpcore/tmp.fsproj.nuget.g.targets ./obj
/usr/bin/dotnet build -c Release
Microsoft (R) Build Engine version 15.3.117.23532
Copyright (C) Microsoft Corporation. All rights reserved.

/home/dunham/.nuget/packages/fsharp.net.sdk/1.0.5/build/FSharp.NET.Core.Sdk.targets(170,9): error MSB6006: "dotnet" exited with code 131. [/home/dunham/benchmarksgame_quadcore/pidigits/tmp/tmp.fsproj]

Build FAILED.

/home/dunham/.nuget/packages/fsharp.net.sdk/1.0.5/build/FSharp.NET.Core.Sdk.targets(170,9): error MSB6006: "dotnet" exited with code 131. [/home/dunham/benchmarksgame_quadcore/pidigits/tmp/tmp.fsproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:02.81
/home/dunham/benchmarksgame/nanobench/makefiles/u64q.programs.Makefile:189: recipe for target 'pidigits.fsharpcore_run' failed
make: [pidigits.fsharpcore_run] Error 1 (ignored)

3.33s to complete and log all make actions

COMMAND LINE:
/usr/bin/dotnet ./bin/Release/netcoreapp2.0/tmp.dll 2000

PROGRAM FAILED 


PROGRAM OUTPUT:

No executable found matching command "dotnet-./bin/Release/netcoreapp2.0/tmp.dll"