Search for a tool
Cantor Expansion

Tool to calculate the Cantor expansion of a number (sum of factorial), thanks to its representation in factorial base.

Results

Cantor Expansion -

Tag(s) : Arithmetics

Share
Share
dCode and more

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!


Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!


Feedback and suggestions are welcome so that dCode offers the best 'Cantor Expansion' tool for free! Thank you!

Cantor Expansion

Cantor Expansion Calculator


See also: Factorial Base

Answers to Questions (FAQ)

What is a Cantor Expansion? (Definition)

The Cantor Expansion of a natural number $ n $ is a sum of the form $$ n = (k_m)m! + (k_{m-1})(m-1)! + \cdots + k_{2}2! + k_{1}1! $$ with integers $ k_i $ such as $ 0 \leq k_i \leq i $

Example: 12 = 2*3! + 0*2! + 0*1!

This is the explicit sum of the factor base of the number $ n $.

How to calculate the Cantor expansion of a number?

Start by converting the number to a factorial basis (by performing successive divisions of $ n $ by $ i $ for the numbers from $ 1 $ to $ n $, as long as the quotient of the Euclidean division is non-zero) and add figures (in factorial basis) obtained by multiplying them by the corresponding factorial.

Example: In base 10, $ 123 $ can be decomposed as $ 1 \times 100 + 2 \times 10 + 3 \times 1 $

Example: In factorial base, $ 234_{10} = 14300_{!} = 1 \times 5! + 4 \times 4! + 3 \times 3! + 0 \times 2! + 0*1! $

What is Cantor expansion algorithm?

To code the conversion of a decimal number into a factorial base, here is an algorithm function decimal2cantor(x) {
n = 1
a = []
while (x != 0) {
a[n] = x mod (n+1)
x = (x-a[n])/(n+1)
n++
}
return a[n]
}

Cantor's expansion can be deduced by a[n]*n! + a[n−1]*(n-1)! + ... + a[2]*2! + a[1]*1!

To code the conversion of a number written in factorial base into a decimal number, here is an algorithm:function cantor2decimal(a[n]) {
x = 0
for i=n to 1 {
x = x + a[i]
x = i*x
}
return x
}

Source code

dCode retains ownership of the "Cantor Expansion" source code. Except explicit open source licence (indicated Creative Commons / free), the "Cantor Expansion" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or the "Cantor Expansion" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "Cantor Expansion" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app!
Reminder : dCode is free to use.

Cite dCode

The copy-paste of the page "Cantor Expansion" or any of its results, is allowed as long as you cite dCode!
Cite as source (bibliography):
Cantor Expansion on dCode.fr [online website], retrieved on 2022-12-08, https://www.dcode.fr/cantor-expansion

Need Help ?

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!

Questions / Comments

Feedback and suggestions are welcome so that dCode offers the best 'Cantor Expansion' tool for free! Thank you!


https://www.dcode.fr/cantor-expansion
© 2022 dCode — The ultimate 'toolkit' to solve every games / riddles / geocaching / CTF.
 
Feedback