You are viewing a single comment's thread. Return to all comments →
The honest-but-not-DP way:
let pentagonals = seq { 1L..100000L } |> Seq.scan (fun pentagonal idx -> pentagonal + idx * 3L - 2L) 0L |> Seq.toArray let n = Console.ReadLine() |> int for _ in seq { 1..n } do pentagonals |> Array.item (Console.ReadLine() |> int) |> printfn "%d"
The cheating way:
let pentagonal n = n * (1.5 * n - 0.5) let n = Console.ReadLine() |> int for _ in seq { 1..n } do Console.ReadLine() |> float |> pentagonal |> int64 |> printfn "%d"
Seems like cookies are disabled on this browser, please enable them to open this website
Pentagonal Numbers
You are viewing a single comment's thread. Return to all comments →
The honest-but-not-DP way:
The cheating way: