Created
March 16, 2016 19:23
-
-
Save adacola/a6e4b0aad271fd13735b to your computer and use it in GitHub Desktop.
階乗進法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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