module Grains let rec safeSqaure n: uint64 = if n = 1 then uint64 (1) else uint64 (2) * safeSqaure (n - 1) let square (n: int): Result = if n < 1 || n > 64 then Error "square must be between 1 and 64" else Ok(safeSqaure n) let total: Result = Ok (List.sumBy (fun x -> let s = square x match s with | Ok (n) -> n | _ -> uint64 (0)) [ 1 .. 64 ])