2835: Factorial Numbers

Explain xkcd: It's 'cause you're dumb.
Revision as of 19:02, 15 March 2024 by (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Factorial Numbers
So what do we do when we get to base 10? Do we use A, B, C, etc? No: Numbers larger than about 3.6 million are simply illegal.
Title text: So what do we do when we get to base 10? Do we use A, B, C, etc? No: Numbers larger than about 3.6 million are simply illegal.


A factorial is a product of positive integers. For instance, four factorial, written '4!', means 4×3×2×1=24.

The "base" of a numbering system defines which numbers it uses as digits and what each place value in a number means. For example, in decimal numbers (base 10), the digits go from 0 to 9, and place values are ones, tens, hundreds, etc. So "137" means 1×100 + 3×10 + 7×1 = 137. Numbers can also be written in other bases, such as binary (base 2, using the digits 0 and 1 and place values of 1, 2, 4, 8...) or octal (base 8, using the digits 0-7 and place values of 1, 8, 64, and so on). Using different bases is uncommon, but is sometimes useful in computer science.

In the comic, Cueball proposes a factorial number system, where the base changes for each place value - the first digit can be 0 or 1, the next digit can be 0, 1, or 2, the third can be 0, 1, 2, or 3, and so on. Each place value is the factorial of the base. So the number 137 in base 10 could be written as 10221, meaning 1×5! + 0×4! + 2×3! + 2×2! + 1×1!. While this numbering system is technically usable and can express any number, it seems excessively complicated, and the only reason Cueball gives for using it is that he thinks large digits like 9 should only be used in vast numbers (9 would not be used unless the number was at least 9 digits long, or over 3.2 million in decimal). This is a silly reason for using a new numbering system,[citation needed] so the math department thinks this is a prank, and has security throw him out.

In the title text, someone points out that a factorial number system needs more and more digits for each place value. The tenth digit in a factorial number would be in base 11, which needs 11 possible digits, and 0-9 only provides 10. In bases higher than 10, you can use letters to represent higher digits. For example, hexadecimal (base 16) goes from 0 to 9, then from A to F. It would be reasonable to do the same thing for higher bases in factorial numbers. Instead, Cueball says that it's simply illegal to write numbers larger than about 3.6 million, the largest you can go without using a base greater than 10. This is an absurd limitation, as other numbering systems can go as high as you like.

The number at the top of Cueball's presentation, 353011, is 3×6! + 5×5! + 3×4! + 0×3! + 1×2! + 1×1! which gives the decimal value of 2835, the number of the comic.

Cueball's examples of numbers written in factored appear as sequences A007623 in the OEIS.


Ambox notice.png This transcript is incomplete. Please help editing it! Thanks.
[Cueball is standing in front of a large poster. There are two uniformed officers (a Ponytail and a further Cueball, wearing badged hats) approaching Cueball.]
Variable-base Factoradic™ numbers
Base 7 Base 6 Base 5 Base 4 Base 3 Base 2
3 5 3 0 1 1
Left side
Base 10 Factoradic
1 1
2 10
3 11
4 20
5 21
6 100
7 101
21 311
22 320
23 321
Right side
Base 10 Factoradic
24 1,000
25 1,001
5,038 654,320
5,039 654,321
5,040 1,000,000
999,998 266,251,210
999,999 266,251,211
1,000,000 266,251,220
1,000,001 266,251,221
Cueball: Small numbers like seven or nineteen shouldn't use big numerals like "7" or "9".
Cueball: I mean, "9" is the biggest numeral we have! It should be reserved for big numbers.
Cueball: Small numbers should be written with small numerals like "1" or "2".
Cueball: That's why my variable-base system uses...Hey! No, listen!
[Caption under the comic:] Factorial numbers are the number system that sounds most like a prank by someone who's about to be escorted out of the math department by security.

comment.png add a comment! ⋅ comment.png add a topic (use sparingly)! ⋅ Icons-mini-action refresh blue.gif refresh comments!


Number systems aren't real math, at least not serious math. They're an affectation. 99.9% of math is number-system-independent, so nobody should care about them. 22:30, 29 September 2023 (UTC)

Of course it's "real math." There aren't that many applications, but so what? Math isn't about applications. Besides, there are some. Maybe not specifically for factorial base, but for some place systems. The only thing "dirty" about decimal is the arbitrariness of ten. Considering place systems in general is just considering special kinds of sums. Certainly, "serious" mathematicians are interested in proving numbers normal in specific bases, or in every base. EebstertheGreat (talk) 01:55, 30 September 2023 (UTC)
A great deal of interesting maths can be found in and around he various arrangements of digits in number systems, surely. AzureArmageddon 07:54, 30 September 2023 (UTC)

I thought this was a complete joke, until coming here. The "factorial number system" exists?! 22:38, 29 September 2023 (UTC)

Yup, complete news to me too... What's REALLY weird: the night before this comic I was tutoring a friend's daughter in math, and I happened to teach her what factorials are! (News to me there's a number system, though)... NiceGuy1 (talk) 04:59, 1 October 2023 (UTC)

I wanted to add a link to a converter, but the one I found is https://www.dcode.fr/factorial-base which is quite ugly with lots of adds and a bit counter-intuitive.--Pere prlpz (talk) 23:42, 29 September 2023 (UTC)

This needs simplifying a bit. Came here because I had no idea what was going on, and after a quick scroll through the prose, the main thing I learned was "it's 'cause you're dumb". May be true but I still don't get what Randall's factorial system is....Alcatraz ii (talk) 01:25, 30 September 2023 (UTC)

Should we move the line about the number at the top of the presentation being the number of this comic to trivia? Seems like it belongs there. B for brain (talk) (youtube channel wobsite (supposed to be a blag) 17:31, 19 January 2024 (UTC)

It seems to be fairly integral to the comic, IMO. Trivia seems to me more for "Incidentally, if we go beyond what the comic directly says..." (though it has been used for more and for less, or not used at all when something might have been relegated to it). Maybe you can consider it an Easter Egg, but it's not even really all that hidden. 19:09, 19 January 2024 (UTC)


I have actually considered this system, though not with any illusion of its being useful. Any system "exists", just as any number "exists". A system where 1 = decimal 1, 10 = decimal 29, 100 = decimal 493 , exists in the monetary system of the Harry Potter world. An actual system existed where 1d = 1d, 1/- = 12d, £1/-/- = 240d.

It's only on seeing that someone else had come up with this system, that it's occurred to me to consider fractions. Any rational number has a finite number of places after the "factoradic" point. Anything with infinite repetition after the point is irrational. 1⁄2 = 0.1

1⁄3 = 0.021 [Corrected: 0.02]

1⁄4 = 0.0121 [Corrected: 0.012]

1⁄5 = 0.01041 [Corrected: 0.0104]

1⁄6 = 0.011 [Corrected: 0.01]

1⁄7 = 0.0032061 [Corrected: 0.003206]

1⁄8 = 0.0031 [Corrected: 0.003]

1⁄9 = 0.002321 [Corrected: 0.00232]

1⁄10 = 0.0022

π = 11.003156502.....

e = 10.11111111111111111111..... 09:34, 13 October 2023 (UTC)

I am not following the fractions presented above after the first - if these are inverses of the left-of-decimal bases (excluding 1!), .1 = 1/2, .01 = 1/6, .001 = 1/24, etc., then I believe the corrections added above are appropriate (mostly removing a trailing 1). If I'm mistaken, perhaps it needs a bit more explanation? Regardless, e as a repeating value is delightful. Majuba 19:49, 17 October 2023 (UTC)


Factorial base also allows to finitely represent all rational numbers - no constant base is capable of that! 01:55, 30 September 2023 (UTC)

Unless you use a division sign. But yes, only radix numerals of a variable base with infinite series of factors of every prime can even theoretically finitely represent arbitrary rationals without invoking existential quantifiers. 06:43, 30 September 2023 (UTC)

I feel like Michael when Oscar is trying to explain what a “surplus” is. 04:12, 30 September 2023 (UTC)

Bruh, same, and I'm a stats major. This "explanation" sorely needs a couple paragraphs of ELI5 introductory exposition for English majors between the first and second sentences. 13:11, 5 October 2023 (UTC)

The warning is complete nonsense, just remove it[edit]

bots cant be escorted out of somewhere just remove the stupid warning 04:28, 30 September 2023 (UTC)

you must be new here - 15:51, 30 September 2023 (UTC)
The nonsense is part of the fun. AzureArmageddon 07:52, 30 September 2023 (UTC)
im deleting it (talk) 11:16, 30 September 2023 (please sign your comments with ~~~~)
Premature elision. Still has a purpose (as does signing your contributions here). 14:58, 30 September 2023 (UTC)
*sigh* As has been stated, you MUST be new here. The "incomplete" tag goes on new comics while their descriptions are still in flux. When the bot creates the empty description page, it does so with the Incomplete warning, labelled with its name. On the first edit, someone ALWAYS changes the name to some silly gag that's related to the comic, often pretending it's the name of the bot that created the page for us. In this case the comic shows Cueball being escorted out, so the joke is the bot is being escorted out. If you're not going to have a sense of humour, why are you here? Just leave the editing to others in the meantime. :) (Oh, and as the user above noted, make sure to end your comments with ~~~~ (4 tildes), like it says at the top of the editing text box you type in). :) NiceGuy1 (talk) 05:13, 1 October 2023 (UTC)
Okay, now the Incomplete warning needs to stay up forever. :) NiceGuy1 (talk) 05:13, 1 October 2023 (UTC)
Sign your comments. :) And yup. Whenever someone makes an unreasonable objection, it MUST be ignored to tech unreasonable people to stop being ridiculous. :) NiceGuy1 (talk) 04:27, 19 November 2023 (UTC)
In case you weren’t aware, this wiki has a tradition of humor. This is one of its examples. 12:56, 2 October 2023 (UTC)

The "adic" part of factor-adic numbers[edit]

It's not explicitly mentioned in the comic but the "adic" in the name "Factoradic™" implies that the number system extends the factorial number system by being in some way "adic" as discussed in this YouTube video on the Veritasium channel and so negative numbers would have a truly wacky representation that violates the intent of the title text's pronouncement by requiring an infinitely long representation requiring infinite digits (1, 2, 3, 4, ..., 9, A, B, C, ..., infinite digits). AzureArmageddon 08:00, 30 September 2023 (UTC)

The "adic" in factoradic doesn't actually relate to p-adic numbers of any kind. Rather, both factoradic and p-adic numbers use the suffix -adic to refer to the concept of adicity, which is "The number of arguments or operands a function or operation takes" according to Wiktionary. Each place value of a p-adic number had p possibilities, and each place value in the factoradic system has a number of possible arguments determined by the factorial of the place. Factoradic would be better called "factorary" since it's more similar to ordinary n-ary number systems, but I guess it just isn't. 20:43, 30 September 2023 (UTC)
Ah, today I learned. AzureArmageddon 15:35, 1 October 2023 (UTC)

Title text[edit]

The title text references that 10! = 3,628,800 (base 10), and so for numbers greater than or equal to that, you would have to add a tenth digit in order to display them in this system. The question is asking whether you would then proceed to using letters of the alphabet such as one does in hexadecimal to which the reply is that numbers above this amount are simply illegal. The trouble comes when you try to write down the number 10 * 10! = 36,288,000 (base 10) in this system. For 10!, the notation is 1000000000 , so 9 * 10! would be 9000000000, and then to get 10 * 10!, you would have to write A000000000 because 10 * 10! < 11!. In fact, since this is the first "illegal" number, you could "legally" allow up to 10 * 10! - 1 = 36,287,999 (base 10) in the system (which would be written as 9987654321 = 9 * 10! + 9 * 9! + 8 * 8! + ... + 2 * 1! + 1 * 1!) without the need to introduce any letters. I also want to point out that the reference in the comic to 9 being reserved for big numbers is due to no number needing a 9 to write it down in this system until 9 * 9! = 3265920 which is written 900000000. Since numbers above 10! are not allowed, this means that only the 9! digit is legally allowed to hold a 9, and it only applies to numbers in that high range of 3265920 to 3628799. 15:01, 30 September 2023 (UTC)

I feel the current in-Explanation explanation about that already covers this, with the addition of the validity that the digit that could need to be >9 could still be any digit 0..9 without needing to invoke the 11th digit. (Maybe a few tweaks, but not sure what you're trying to add here.) 15:13, 30 September 2023 (UTC)

Radix Economy[edit]

Someone got in there just before I did, about (from a quick scan of what's been added) "economical" use of Factorial-based variable radices. (I was planning both the test code and the explanation for this, whilst travelling.) My short way of putting it is that (apart from values of zero or one, which represent identically in Factorial-based notation to any other notation in base of 2+) the Factorialised method initially is using up 'places' quicker until the point at which it has reached a 'magnitude' equal to its base-normal 'original' (i.e. only when there are N glyphs made available under Factoradic notation does it not rush through the 'magnitude' quicker than the base-N number). And then, it needs to work up into the more 'efficient' higher-order digits in order to pull back the disadvantages of its lower-order ones and equal, then be shorter than, any given value's respective base-N form.
Now, I've done some very rough calculations (started hitting numbers for which I really need to convert everything into high-precision large-number data types, which needs me to rewrite one or two elements of my existing code) and looked at the successive changes of magnitude, in each base, and checked the calculated Factoradic length (with the assumption that there are enough extended glyphs to represent every digit singly, unlike the comic Title Text speculation).
By my reckoning, Base-2 is more efficient at 20fact (compare with 1002, =410); Base-3 breaks better at 3111fact (100003, =81); Base-4: 540220fact (10000004, =4096); Base-5: 533340021fact (10000000005, =1953125); Base-6: 90967344000fact(1000000000006, =362797056); Base-7: 7ABAA086002001fact(1000000000000007, =678223072849); Base-8: D73A256860540220fact(100000000000000008, =281474976710656); Base-9: B1HEA65678836651220fact(100000000000000008119, =1350851717672992000) ...but at this point, the conversion of decimal to its base-9 form (and that powers of 9 should never have trailing zeros!) shows I may very well have hit a limit to normal large-number precision, so I really can't trust the subsequently derived base-10 values.
But, in case anyone wants it, the following is my (Perl, but should be easily convertible into most medium-to-high level code dialevts) en-Factoriadialising function.

sub factadic { my ($n,$place)=(@_,1);
  return () unless $place;
  if ($n>=fact($place+1)) { return factadic($n,++$place) }
  my $digit=0; my $base=fact($place);
  while ($n>=$base) { $digit++; $n-=$base; }
  my @return=($digit,factadic($n,$place-1));
  return @return;

You call it as factadic(<value>). Or factadic(<value>,<minimum_digits>) to start with the assumption of at least a minimum number of digits, but it'll start by shifting the default minimum of 1 into the <script>$place</script> variable if you don't give it that (there are other ways that you can/must do that, of course), and it will still always expand that to the degree necessary in the first phase of 'diving in' as far as it needs to in order to agree with the fact() function (factorial calculator, a trivial coding issue that I only use here like this because I alreadu set it up for another bit of code).
It returns an array (@-variable, in Perl) of digits, in standard most-to-least-significance order, that you can convert to a glyphwise notation in any way that you wish (or do a string conversion within the function, at each stage of building it up). ...and I'm presenting a slightly less optimised version of it here (some of the Perl-tricks I originally used don't translate well into some non-Perl) and, yes, the while ($n>=$base) loop could be done using modulus and integer-division, but it's a fairly trivial part of the looping process.
If you have any real problems with it, it's probably going to be if you're hitting any recursion-depth limits (especially as it uses roughly twice as many recursive calls as the eventual notation-length it produces). I also have a 'stack-based' version (loops round as it shifts in enough 'slots', then works back down again assigning the place-values) which avoids such trouble, but that's coded in a slightly esoteric Perlish way that I'm not sure most of you'd appreciate. ;) 20:25, 30 September 2023 (UTC)

Probably a double precision floating point accuracy limitation, you can only get up to 2^53 = 9007199254740992 before many modern programs start getting numerically fuzzy. But what weirds me out is you seem to have gotten 1350851717672992900 out of what should have been 9^19 = 1350851717672992089, instead of a nearby float of 1350851717672992768 or 1350851717672993024. What is it with things rounding to decimal like that? 11:43, 1 October 2023 (UTC)
One 'solution' is to use Math::BigFloat (or similar), in the Perl, and make hold such sensitive and large-tending values. Alternately, implement an array of digits in a raw manner (can be of entirely arbitrary base, explicitly, plus arbitrarily long; well, as long as one doesn't hit other data limits!) and make your own long-division/etc algorithms. Or pack bitwise/bytewise data as a 'string', with suitable overloaded/replacement mathematical functions. But it all adds extra coding effort, of course. And I rarely share my various hacked-together bits of Perl, because they either work but look horrible or they don't work (and probably look strange, even to me - hence why I've failed to discover why they don't work!). 19:39, 1 October 2023 (UTC)
Just analyzed the growth rate; For base x, the length can be estimated by 1/2+e*x-e-1.487*ln(x). Maybe a more sniped nerd can get more precision, or even an exact solution; but this is within a digit of the result up to around base 10^13, and then I start running into precision problems in general, so I'm just putting this here as a good enough guess. 13:20, 1 October 2023 (UTC)

Factorial numbers is new to me... It sounds more like a coding system than a number system, LOL! "The door code is 4503 in factorial! Figure it out!" (I'd write this on the bottom of the comments as usual, but I don't want to get mixed up with that ill-thought out and unsigned coding sample Algorithm and table that I KNOW must be mangled when published because the wiki refuses to honour single Newlines. Clearly the author didn't take a peek at what it looks like when published EDIT: Correction, wow, the wiki spotted the code and marked it as such automatically (for now), wow!) :) NiceGuy1 (talk) 04:59, 1 October 2023 (UTC)

All the stuff about economy / efficiency doesn't seem to really have any direct relation to the comic, so I'd suggest it doesn't really belong in the explanation, but should be confined to the comments, or at least to a trivia section. Not least because it dives off into a lot of technical stuff that itself requires explanation for a significant part of the readership. As it is, it's doing more to confuse than to explain. 09:02, 2 October 2023 (UTC)

I sort of agree, in that I had planned something similar about 'notation economy' as a Trivia-like addendum, before others got there before me. But there could at least be something to be said that by reserving higher-digits(/dissalowing them in lower values), Cueball/Randall is sacrificing conciseness for (one idea of) aestheticism. (And that's without going into 'how much storage it takes to store each digit', which I wasn't going into. So rather than the idealised radix being base-'e', I would have said the idealised base was whatever base-number exceeded the highest value, so it was just one (different) single squiggle for everything. Obviously, there's necessary entropy in the choice of differentiatable squiggles/encoding, though, which is why I also appreciate the current Explanation's blurb.) 10:15, 2 October 2023 (UTC)

NiceGuy1 the wiki uses standard markdown, if you preface with 6 spaces, it will automatically recognize it as a code snippit. I appologize if my contribution was ill-thought out, though i have gone back and signed it. Drinkcoffeeandcode (talk) 20:06, 4 October 2023 (UTC)

I called it "ill-thought out" for having no tags or markup, and thus figured it would be all mangled. :) I was mistaken. Good to know, except I don't see myself ever sharing code (I figure people generally aren't hanging out in a coding environment to just run random code like that. I myself don't have any place to try it these days, and if I did I don't prefer C so probably wouldn't have a C environment anyway). But the last time I wrote someone after an unsigned comment, some idiot manually marked it as mine (WHY would I reply to myself?), which I removed, and I don't know how to manually write someone else's sign in (and didn't want to hunt one down to SEE and learn how), so it's probably STILL unsigned. Usually when there's an unsigned comment someone who knows how checks the edit history to find the IP or name to add it. :) Oh, and usually if you want to reply to someone, you put a colon and place your reply below theirs (like this). :) NiceGuy1 (talk) 04:29, 7 October 2023 (UTC)

Factoradic Algorithms[edit]

there are several ways to compute the factoradic of a base 10 number, depending on the choice of language the length of the program will be demonstrably bigger. Dynamically typed languages, like perl can likely perform this in one or two lines, where as a language like c++ will be longer.

The simplest algorithm is to generate the digits from right to left one at time by dividing the number by a per-iteration-incrementing radix starting from 2 (because 1 is simply '0', we start from 2), taking the result and repeating until the quotient reaches zero:

    #include <iostream>
    #include <algorithm>
    using namespace std;
    int factoradic(int num) {
       string digits;
       int radix = 2;
       while (num != 0) {
           digits.push_back(((num % radix)-'0'));
           num /= radix++;
       reverse(digits.begin(), digits.end());
       return atoi(digits.c_str());

Using Randall's values we can confirm it is correct:

    int main(int argc, char* argv[]) {
        for (int i = 21; i < 26; i++) 
            cout<<i<<" - "<<factoradic(i)<<endl;
        for (int i = 5038; i < 5042; i++) 
            cout<<i<<" - "<<factoradic(i)<<endl;
        for (int i = 999998; i < 1000002; i++) 
            cout<<i<<" - "<<factoradic(i)<<endl;
        return 0;
    max@laptop:~/$ ./factoradic
    21 - 311
    22 - 320
    23 - 321
    24 - 1000
    25 - 1001
    5038 - 654320
    5039 - 654321
    5040 - 1000000
    5041 - 1000001
    999998 - 266251210
    999999 - 266251211
    1000000 - 266251220
    1000001 - 266251221

Came back to sign code sample after seeing NiceGuy1's comment. Drinkcoffeeandcode (talk) 20:02, 4 October 2023 (UTC)

I would love to have some kind of explanation as to why this number system exists/what it's used for in the real world. (Even if that explanation is just "there's no practical purpose, mathematicians just love doing this stuff".) 14:55, 2 October 2023 (UTC)

Would it be too much of a fandom crossover to edit / annotate the last word of the explanation (at time of commenting, the word "senary") to "seximal"? Or, given that we are discussing intentionally silly base systems, just the right amount of a fandom crossover? 08:14, 5 October 2023 (UTC)

"Fandom crossover" with what, exactly? Just humour for Beavis & Butthead/Quagmire-style "sex, hee hee" people (such as myself), or is there some actual fandom you're referring to? As it is, I would have thought the proper word WOULD have "sex" in it, like sextillion does... :) NiceGuy1 (talk) 05:41, 7 October 2023 (UTC)
I'm assuming the jan Misali fandom. The guy is mostly known for his videos on constructed languages, but he also has strong opinions on base 6. As a reference, see his site seximal.net.

Can I politely note that your algorithm potentially has no end? num is never 0 because you're always dividing and never subtracting. My perl attempt goes through every radix up to around 180 before giving up. (Leave out the atoi and you'll see what I mean.) I might recommend capping radix at 9. Hymie (talk) 12:20, 9 October 2023 (UTC)


There should be a category where presenters are escorted by security, or are about to be.-- 12:27, 6 October 2023 (UTC)

You may be right, I recall several (none specific come to mind, but I know it's a scenario Randall clearly enjoys). NiceGuy1 (talk) 05:41, 7 October 2023 (UTC)


wikipedia:Factorial number system uses the 3121! style notation. Should probably be used in the explanation, together with the 8310 notation. -- 12:42, 6 October 2023 (UTC)

"In this article, a factorial number representation will be flagged by a subscript '!'", that sounds like it's not a standard notation, just one THAT editor used for THAT article to clarify things when explaining it. NiceGuy1 (talk) 05:44, 7 October 2023 (UTC)
It's used at least in a *Scientific American* article from 4 years ago: https://blogs.scientificamerican.com/roots-of-unity/its-factoradical/


It doesn't seem that this number system actually has that much practicality. Perhaps this can be proven wrong though. (talk) 00:28, 28 January 2024 (please sign your comments with ~~~~)

There's already some pointers as to what it's practical at, above...
At the very least, it gives an easier-to-use (from representation to implementation) rearrangement, knowing that you just have to slice off bits of both the sort-key (shifting off a digit at a time, to get N1, N2, N3... etc) and the source-sequence (splicing out the N1th, N2th, N3th... etc). Easier than saying "try the 2835th recombination plan".
But that's just the most trivial use, a mere abstract compared to some more complex topological uses that map 1:1ish against number theory. Use your imagination! 00:59, 28 January 2024 (UTC)

I like how 101 dalmatians can now be 7 dalmatians[edit]

87.bus.rider (talk) 11:28, 15 March 2024 (UTC)