Handbook
Glossary
factoradic ( n -- factoradic )
Vocabulary
math
.
combinatorics
.
private
Inputs
n
an
integer
Outputs
factoradic
a
sequence
Word description
Converts a positive integer
n
to factoradic form. The factoradic of an integer is its representation based on a mixed radix numerical system that corresponds to the values of
n
factorial.
Examples
USING: math.combinatorics.private prettyprint ; 859 factoradic .
{ 1 1 0 3 0 1 0 }
Definition
USING:
kernel
math
sequences
;
IN:
math.combinatorics.private
:
factoradic
( n -- factoradic )
0
[
over
0
>
]
[
1
+
[
/mod
]
1check
]
produce
reverse!
2nip
;