Files
project-euler/45.fs
T
2025-08-03 20:16:55 -07:00

18 lines
521 B
FSharp

module _45
let triPentHex =
let limit = 100000
let opDict (op : int -> bigint) =
[1..limit]
|> Seq.map (fun n -> (op n, n))
|> dict
let p = opDict common.pentagonalNumber
let h = opDict common.hexagonalNumber
common.allIntegers
|> Seq.skip 284
|> Seq.map (fun i -> (common.triangleNumber i, i))
|> Seq.filter (fst >> (fun t -> p.ContainsKey(t) && h.ContainsKey(t)))
|> Seq.map (fun t -> (snd t, p.Item(fst t), h.Item(fst t), fst t))
|> Seq.take 2