Sha256: 4a463a940b250257631de51ac9119c81e50bf17c26bf0fcb8f7fd0c370019444

Contents?: true

Size: 319 Bytes

Versions: 132

Compression:

Stored size: 319 Bytes

Contents

module Grains

open System.Numerics

let square (n:int) = 
    if n <= 0 || n > 64 then 
        Error "Invalid input"
    else
        Ok (2I ** (n - 1) |> uint64)

let total = 
    [1..64] 
    |> List.map square
    |> List.reduce (fun x y -> match x, y with Ok a, Ok b -> Ok (a + b) | _ -> Error "Invalid input")

Version data entries

132 entries across 132 versions & 1 rubygems

Version Path
trackler-2.2.1.78 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.77 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.76 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.75 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.74 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.73 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.72 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.71 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.70 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.69 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.68 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.67 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.66 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.65 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.64 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.63 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.62 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.61 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.60 tracks/fsharp/exercises/grains/Example.fs
trackler-2.2.1.59 tracks/fsharp/exercises/grains/Example.fs