Skip to content

Instantly share code, notes, and snippets.

@adacola
Created March 16, 2016 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adacola/a6e4b0aad271fd13735b to your computer and use it in GitHub Desktop.
Save adacola/a6e4b0aad271fd13735b to your computer and use it in GitHub Desktop.
階乗進法
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