Factoradic Converter

In factoradic
—
—
Places used
—
Largest place
—
Most these places hold
—
Also an ordering
—
Each place, and what it adds

Every place is worth a factorial. The dots show how full each place is: the k! place holds at most k.

How it's worked out

A neat property: in decimal, 1/3 never ends (0.333…). In factoradic every fraction ends: 1/3 is exactly 0.0:0:2 and 1/7 is 0.0:0:0:3:2:0:6. That's because every whole number divides some factorial, so multiplying by 1, 2, 3, … always clears the denominator eventually. Only irrational numbers such as e = 1:0:0.0:1:1:1:1:… go on forever.

Factoradic converter: decimal to factorial number system and back, for whole numbers of any size, negatives and fractions, with every place value and the division steps shown.

Ordering
—
—
Items
—
Orderings in all
—
Lehmer code
—
Through the list
—
Pick by pick

Read the Lehmer code from the left. Each digit says which of the items still left to take, counting from 0.

Its neighbours in the list in dictionary order, click one to jump
NumberOrdering

Why this works: the first item can be chosen n ways, the next n − 1 ways, and so on down to 1. Those shrinking choices are exactly the digit limits of factoradic: the (n − 1)! place allows 0 to n − 1, the next place one fewer, down to the 0! place, which is always 0. So the numbers 0 to n! − 1 and the n! orderings match up one to one, in dictionary order.

Permutation rank and unrank calculator: find the k-th permutation of a list or the position of a given permutation, using the Lehmer code and the factorial number system, for lists of up to 60 items.

Counting in factoradic
0
Press Start counting, or step one at a time.
The wheels

Highest place on the left. Under each wheel: its place value, and the digits it can show.

The first 24 numbers each is also one ordering of A B C D
DecimalFactoradicOrdering of A B C D

The rollover rule: 1 × 1! + 2 × 2! + 3 × 3! = 1 + 4 + 18 = 23, one less than 4! = 24. In general the fullest number that fits below the k! place is always k! − 1, just as 999 is one less than 1000 in decimal. That's why the wheels roll over so neatly.

Counting in the factorial number system: an animated odometer showing how factoradic digits carry, with the numbers 0 to 23 and the matching permutations of four items.

Read before using
The fine print
What the factorial number system is, how the conversions work, and what it's good for.
Common questions
What is the factorial number system?

It's a positional number system in which each place is worth a factorial instead of a power of ten. Reading from the right, the places are worth 0! = 1, 1! = 1, 2! = 2, 3! = 6, 4! = 24, 5! = 120 and so on, and the digit in the k! place can be any whole number from 0 to k. Every whole number has exactly one way to be written like this. Numbers written this way are called factoradic, and because the base changes from place to place it's known as a mixed-radix system.

Why can each digit go no higher than its place number?

Because (k + 1) × k! equals (k + 1)!, the value of the next place. A digit of k + 1 would simply be a 1 in the next place up. It also means the fullest number that fits below a place is exactly one less than that place: 1 × 1! + 2 × 2! + 3 × 3! = 23 = 4! − 1, just as 999 = 1000 − 1 in decimal.

How do I convert a decimal number to factoradic?

Divide the number by 1, then divide the quotient by 2, that quotient by 3, and so on until the quotient is 0. The remainders, read from last to first, are the factoradic digits. For 463 the remainders are 0, 1, 0, 1, 4, 3, so 463 = 3:4:1:0:1:0.

How do I convert factoradic back to decimal?

Multiply each digit by the factorial of its place and add everything up. For 3:4:1:0:1:0 that's 3 × 5! + 4 × 4! + 1 × 3! + 0 × 2! + 1 × 1! + 0 × 0! = 360 + 96 + 6 + 0 + 1 + 0 = 463.

Why does every factoradic number end in 0?

The last place is the 0! place, and a digit there can only go up to 0. It carries no information, so many texts leave it out and write 463 as 3:4:1:0:1. The converter can show it either way; the setting is under Notation.

Can factoradic show fractions?

Yes. Places after the point are worth 1/1!, 1/2!, 1/3!, …, and the digit in the 1/k! place goes up to k − 1. To convert, multiply the fraction part by 1, 2, 3, … in turn, keeping the whole-number part each time as the next digit. Every fraction ends after a finite number of places, because its denominator always divides some factorial: 1/3 = 0.0:0:2 and 1/7 = 0.0:0:0:3:2:0:6. The number of places needed is the smallest n for which the denominator divides n!.

What is factoradic used for?

Mostly for numbering permutations. The n! orderings of n items match the numbers 0 to n! − 1 one to one, and a number's factoradic digits, called its Lehmer code, say exactly which item to pick at each step. That lets programs jump straight to the millionth ordering of a list, store a shuffle as a single number, or pick a random permutation by picking one random number. The Numbering Orderings tab does this for up to 60 items.

How large a number can the converter handle?

It uses exact whole-number arithmetic, so there's no rounding and no fixed limit: 2⁶⁴, 52! and numbers with hundreds of digits all convert exactly. The input boxes accept up to 1,500 decimal characters. Fractions are expanded to up to 200 places after the point; the few that need more are flagged.

Is anything I type sent anywhere?

No. All the math runs in your browser. Your last number and settings are saved only in this browser's local storage so they're there next time.

Where it comes from: Charles-Ange Laisant described numbering permutations with factorial digits in 1888. The digits are called a Lehmer code after the mathematician D. H. Lehmer, who used the idea in early computer work on combinatorics.

How the factorial number system works: place values, digit limits, converting decimal to factoradic and back by hand, the always-zero place, factoradic fractions, and the Lehmer code for permutations.