Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
階乗進法
let factorialNumberSystem n =
let n = n - 1
let factorials =
if n = 0 then [1]
else
Seq.initInfinite ((+) 2) |> Seq.scan (*) 1 |> Seq.takeWhile ((>=) n)
|> Seq.toList |> List.rev
let factoradic k =
(k, factorials) |> List.unfold (function
| _, [] -> None
| x, f::fs -> Some(x / f, (x % f, fs)))
[for i in 0 .. n -> factoradic i]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment