[Question]
  [
## Introduction:
A 3x3x3 Rubik's Cube has \$43,252,003,274,489,856,000\$ possible permutations, which is approximately 43 [quintillion](https://en.wikipedia.org/wiki/Names_of_large_numbers). You may have heard about this number before, but how is it actually calculated?
A 3x3x3 Rubik's Cube has six sides, each with nine stickers. Looking at the (external) pieces instead of stickers however, we have six center pieces; eight corners pieces; and twelve edge pieces. Since the centers can't be moved, we can ignore those in the calculations. As for the corners and edges:
* There are \$8!\$ (\$40,320\$) ways to arrange the eight corners. Each corner has three possible orientations, although only seven (of the eight) can be oriented independently; the orientation of the eighth/final corner depends on the preceding seven, given \$3^7\$ (\$2,187\$) possibilities.
* There are \$\frac{12!}{2}\$ (\$239,500,800\$) ways to arrange the twelve edges. The halve from \$12!\$ is because edges must always be in an [even permutation](https://en.wikipedia.org/wiki/Parity_of_a_permutation) exactly when the corners are. Eleven edges can be flipped independently, with the flip of the twelfth/final edge depending on the preceding eleven, given \$2^{11}\$ (\$2,048\$) possibilities.
Putting this together, we have the following formula:
$$8!×3^7×\frac{12!}{2}×2^{11} = 43,252,003,274,489,856,000$$
[Source: Wikipedia - Rubik's Cube Permutations](https://en.wikipedia.org/wiki/Rubik%27s_Cube#Permutations)
Although this may already look pretty complex, it's still rather straight-forward for a 3x3x3 Cube. For even cubes the formula is slightly different; this is the formula for a 4x4x4 Cube for example:
$$\frac{8!×3^7×24!^2}{24^7} = 7,401,196,841,564,901,869,874,093,974,498,574,336,000,000,000$$
Which is approximately 7.40 [quattuordecillion on the short scale](https://en.wikipedia.org/wiki/Names_of_large_numbers).
And for larger NxNxN Cubes (i.e. the current World Record 33x33x33) the formula will be extended quite a bit. To not make this introduction too long however, I put these links here instead, where the permutations of the 4x4x4 Cube and some other sized NxNxN Cubes are explained with a resulting formula:
* [2x2x2](https://en.wikipedia.org/wiki/Pocket_Cube#Permutations)
* [4x4x4](https://en.wikipedia.org/wiki/Rubik%27s_Revenge#Permutations)
* [5x5x5](https://en.wikipedia.org/wiki/Professor%27s_Cube#Permutations)
* [6x6x6](https://en.wikipedia.org/wiki/V-Cube_6#Permutations)
* [7x7x7](https://en.wikipedia.org/wiki/V-Cube_7#Permutations)
* [33x33x33](http://twistypuzzles.com/forum/viewtopic.php?f=15&t=32641&start=42)
You may be wondering by now: is there a general formula based on \$N\$ for any \$N\$x\$N\$x\$N\$ Cube? There certainly is. Here are three completely different algorithms, all giving the exact same results based on \$N\$:
1: Chris Hardwick's Formula:
$$\frac{(24×2^{10}×12!)^{N\pmod2}×(7!×3^6)×(24!)^{\lfloor{\frac{1}{4}×(N^2-2×N)}\rfloor}}{(4!)^{6×\lfloor{\frac{1}{4}×(N-2)^2}\rfloor}}$$
[Try it on WolframAlpha.](https://www.wolframalpha.com/input/?i=for+n+%3D+3,+((24*2%5E10*12!)%5EMod%5Bn,+2%5D+7!3%5E6+24!%5EFloor%5B(n%5E2+-+2+n)%2F4%5D)%2F4!%5E(6+Floor%5B(n+-+2)%5E2%2F4%5D))
2: Christopher Mowla's trig Formula:
$$8!×3^7×\left(\frac{24!}{(4!)^6}\right)^{\frac{1}{4}×((N-1)×(N-3)+\cos^2(\frac{N×\pi}{2}))}×(24!)^{\frac{1}{2}×(N-2-\sin^2(\frac{N×\pi}{2}))}×(12!×2^{10})^{\sin^2(\frac{N×\pi}{2})}×\frac{1}{24^{\cos^2(\frac{N×\pi}{2})}}$$
[Try it on WolframAlpha.](https://www.wolframalpha.com/input/?i=for+n%3D3,+8!*3%5E7*((24!)%2F(4!)%5E6)%5E(1%2F4*((n-1)*(n-3)%2Bcos%5E2((n*pi)%2F2)))*(24!)%5E(1%2F2*(n-2-sin%5E2((n*pi)%2F2)))*(12!*2%5E10)%5E(sin%5E2((n*pi)%2F2))*1%2F24%5E(cos%5E2((n*pi)%2F2)))
3: Christopher Mowla's primes Formula:
$$2^{\frac{1}{2}×(2×N×(N+7)-17-11×(-1)^N)}×3^{N×(N+1)+2}×5^{\frac{1}{2}×(2×N×(N-2)+1+(-1)^N)}×7^{\frac{1}{8}×(6×N×(N-2)+3+5×(-1)^N)}×11^{\frac{1}{4}×(2×N×(N-2)-1+(-1)^N)}×96577^{\frac{1}{8}×(2×N×(N-2)-3+3×(-1)^N)}$$
where \$96577\$ is \$(13×17×19×23)\$.
[Try it on WolframAlpha.](https://www.wolframalpha.com/input/?i=for+n%3D3,+2%5E((2n(n%2B7)-17-11(-1)%5En)%2F2)3%5E(n(n%2B1)%2B2)5%5E((2n(n-2)%2B1%2B(-1)%5En)%2F2)7%5E((6n(n-2)%2B3%2B5(-1)%5En)%2F8)11%5E((2n(n-2)-1%2B(-1)%5En)%2F4)96577%5E((2n(n-2)-3%2B3(-1)%5En)%2F8))
[Source: Cubers-reddit - Mathematical Counting Formulas of Number of Positions, God's Number, etc.](https://www.reddit.com/r/Cubers/comments/43xzov/mathematical_counting_formulas_for_number_of/)
## Challenge:
Choose and implement one of these three formulas (or your own derivative), which given an input-integer \$N\$ in the range \$[2,100]\$, outputs the correct result.
## Challenge rules:
* You are free to use another formula besides these three, but keep in mind that these three are proven to be correct. If you use another formula, please add a link of where you got it from (or if you come up with it yourself add an in-depth explanation). And I will check for all integers in the range if the output is correct. Perhaps inspiration could be found in [the oeis for this sequence: A075152](http://oeis.org/A075152).
* If your language automatically outputs a scientific output (i.e. \$1.401...×10^{45}\$ instead of the number after the 4x4x4 formula) this is allowed. But please add additional code to your answer to convert this scientific rounding to an exact output so the results can be verified, since rounding errors due to floating point precision during the execution of the formula in your code is not allowed - the actual result should be exact.
* Your program/function should be correct for at least the inputs in the range \$[2,100]\$ (although, since \$N=100\$ already results in a huge-ass number, any larger \$N\$ will probably work as well if you're able to output this one correctly).
* You are not allowed to loop over all possible permutations with a counter, since that would never output anything in a reasonable amount of time. Only the implementation of a formula (either one of the three provided, a derivative of one of those, or a completely new formula), or another method that will give the correct results in a reasonable amount of time (without hard-coding of course) is allowed. I thought about adding a [restricted-time](/questions/tagged/restricted-time "show questions tagged 'restricted-time'") to enforce this, but I'm personally against [restricted-time](/questions/tagged/restricted-time "show questions tagged 'restricted-time'") in combination with [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so I won't. Still, please make sure your program gives the answers, and if it's too slow for TIO for some reason, add some screenshots with the output from your local machine as verification.
## General rules:
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer in bytes wins.  
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
* [Standard rules apply](https://codegolf.meta.stackexchange.com/questions/2419/default-for-code-golf-program-function-or-snippet/2422#2422) for your answer with [default I/O rules](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods/), so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
* [Default Loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden.
* If possible, please add a link with a test for your code (i.e. [TIO](https://tio.run/#)).
* Also, adding an explanation for your answer is highly recommended.
## Test cases:
Here the test cases for \$N\$ in the range \$[2,10]\$ (feel free to use the WolframAlpha links above for larger test cases):
```
n=2
3674160
n=3
43252003274489856000
n=4
7401196841564901869874093974498574336000000000
n=5
282870942277741856536180333107150328293127731985672134721536000000000000000
n=6
157152858401024063281013959519483771508510790313968742344694684829502629887168573442107637760000000000000000000000000
n=7
19500551183731307835329126754019748794904992692043434567152132912323232706135469180065278712755853360682328551719137311299993600000000000000000000000000000000000
n=8
35173780923109452777509592367006557398539936328978098352427605879843998663990903628634874024098344287402504043608416113016679717941937308041012307368528117622006727311360000000000000000000000000000000000000000000000000
n=9
14170392390542612915246393916889970752732946384514830589276833655387444667609821068034079045039617216635075219765012566330942990302517903971787699783519265329288048603083134861573075573092224082416866010882486829056000000000000000000000000000000000000000000000000000000000000000
n=10
82983598512782362708769381780036344745129162094677382883567691311764021348095163778336143207042993152056079271030423741110902768732457008486832096777758106509177169197894747758859723340177608764906985646389382047319811227549112086753524742719830990076805422479380054016000000000000000000000000000000000000000000000000000000000000000000000000000000000
```
*NOTE: Since this is a [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenge, it basically boils down to: implement one of these three formulas (or a derivative / your own method that still produces the correct results) as short as possible.*
  
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 59 bytes
```
f@n_:=(s=24^6)(24!/s)^(m=n-2)f@m
f@2=7!3^6
f@3=4!12!2^10f@2
```
[Try it online!](https://tio.run/##DchBCoAgEEDRfafInUJhjlIQDHiEaBsZElktdJHef3Lzefzoy3NFX97TEwWbjhl5RjBuFBwMk1k4HjH1IIKNTbCAE9NurNJomAIGTg110/K9qbTStqFm9em@NujUsBP9 "Wolfram Language (Mathematica) – Try It Online")
uses Herbert Kociemba's algorithm found in [OEIS page](http://oeis.org/A075152)
here is the recursive formula:  
`a(1)=1; a(2)=7!*3^6; a(3)=8!*3^7*12!*2^10; a(n)=a(n-2)*24^6*(24!/24^6)^(n-2)` 
*6 bytes saved by @Peter Taylor*
*one more byte saved by @Expired Data* 
[Answer]
# x86 machine code, 119 bytes
Hexdump:
```
60 c6 02 02 33 db be 25 01 10 00 f6 c1 01 74 05
be 26 2a b2 36 33 ed 51 b1 06 33 ff 53 8a 04 1a
f6 e1 03 c7 b5 0a f6 f5 88 64 1a 02 66 98 8b f8
4b 79 ea 5b 43 43 f6 f5 66 89 02 84 c0 75 0c 60
8b fa 8d 72 01 8b cb f3 a4 61 4b 41 d1 ee 72 ca
75 f9 be 1d d4 0d 10 4d 79 be 59 49 49 8b e9 be
06 02 02 22 83 f9 02 73 ae c6 44 1a 01 00 80 0c
1a 30 4b 79 f9 61 c3
```
The function receives the number `n` in `ecx`, and a pointer to a string to fill in `edx` (i.e. `fastcall` convention).
Before I show the source code, some explanations on how it does the thing. It uses the recursive formula, which I wrote in the following way:
```
init = 2
m1 = 24^6 = 6*8*9*16*24*32*36
m2 = 24!/24^6 = 6*7*9*10*11*17*19*21*22*23*25*26*35
num(2) = init * 6*7*9*12*15*27
num(3) = init * 6*8*9*12*16*18*20*24*27*28*30*32*33*35*36
num(n+2) = num(n) * m1 * m2^n
```
So all the code should do is multiplication by small numbers. The numbers are in the range 6...36, which is small enough to be represented in a 32-bit bitmap. I actually don't store the bit which represents multiplication by 6 - this lets me arrange the code in a `do-while` loop, starting with unconditional multiplication by 6.
The big numbers are represented using decimal form - each byte is a value in the range 0...9, starting from the MSB.
The multiplication is performed from LSB to MSB; it assumes that the number of digits will grow by 2 for each multiplication. After doing multiplication by a small factor like 6, the number of digits may grow by only 1. So if MSB = 0, it moves the whole intermediate result left. It can actually happen that the number of digits doesn't grow at all, and then MSB will still be 0, but this problem will fix itself as the code proceeds to greater factors.
Because the multiplication code is large, I don't want to put it twice. I don't want to move it to a function either, because the machine code for calling a function is large. So I rearranged the outer loops in such a way that the multiplying code is needed only once.
C code:
```
void num(int n, char* x)
{
    *x = 2;
    int len = 1;
    int exp_i;
    uint32_t m32_1;
    int m1;
    int carry;
    int temp;
    int str_i;
    bool cf;
    if (n % 2 == 0)
    {
        m32_1 = 0x100125; // 6*7*9*12*15*27
    }
    else
    {
        m32_1 = 0x36b22a26; // 6*8*9*12*16*18*20*24*27*28*30*32*33*35*36
    }
    exp_i = 0;
    while (true)
    {
        for (; exp_i >= 0; --exp_i)
        {
            m1 = 6;
            cf = true;
        do_mult:
            carry = 0;
            for (str_i = len - 1; str_i >= 0; --str_i)
            {
                temp = x[str_i] * m1 + carry;
                x[str_i + 2] = temp % 10;
                carry = temp / 10;
            }
            len += 2;
            x[1] = carry % 10;
            carry /= 10;
            x[0] = carry;
            if (carry == 0)
            {
                --len;
                for (str_i = 0; str_i < len; ++str_i)
                    x[str_i] = x[str_i + 1];
            }
        shift_m1:
            ++m1;
            cf = m32_1 & 1;
            m32_1 >>= 1;
            if (cf)
                goto do_mult;
            if (m32_1)
                goto shift_m1;
            m32_1 = 0x100dd41d; // 24!/24^6 = 6*7*9*10*11*17*19*21*22*23*25*26*35
        }
        --n;
        --n;
        exp_i = n;
        if (n < 2)
            break;
        m32_1 = 0x22020206; // 24^6
    }
    x[len] = 0;
    for (str_i = len - 1; str_i >= 0; --str_i)
    {
        x[str_i] += '0';
    }
}
```
Disassembly:
```
60                     pushad;
C6 02 02               mov byte ptr [edx], 2; // edx = x
33 DB                  xor ebx, ebx; // ebx = len - 1
BE 25 01 10 00         mov esi, 0x100125; // esi = m32_1
F6 C1 01               test cl, 1;
74 05                  jz skip1;
BE 26 2A B2 36         mov esi, 0x36b22a26; // esi = m32_1
                   skip1:
33 ED                  xor ebp, ebp; // ebp = exp_i
                   loop_n:
51                     push ecx;
                   loop_exp_i:
B1 06                  mov cl, 6; // cl = m1
                   do_mult:
33 FF                  xor edi, edi; // edi = carry
53                     push ebx; // ebx = str_i
                   loop_str_i:
8A 04 1A               mov al, [edx + ebx];
F6 E1                  mul cl;
03 C7                  add eax, edi;
B5 0A                  mov ch, 10;
F6 F5                  div ch;
88 64 1A 02            mov [edx + ebx + 2], ah;
66 98                  cbw;
8B F8                  mov edi, eax;
4B                     dec ebx;
79 EA                  jns loop_str_i;
5B                     pop ebx; // ebx = len - 1
43                     inc ebx;
43                     inc ebx;
F6 F5                  div ch;
66 89 02               mov [edx], ax;
84 C0                  test al, al;
75 0C                  jnz skip2;
60                     pushad;
8B FA                  mov edi, edx;
8D 72 01               lea esi, [edx + 1];
8B CB                  mov ecx, ebx;
F3 A4                  rep movsb;
61                     popad;
4B                     dec ebx;
                   skip2:
                   shift_m1:
41                     inc ecx;
D1 EE                  shr esi, 1;
72 CA                  jc do_mult;
75 F9                  jnz shift_m1;
BE 1D D4 0D 10         mov esi, 0x100dd41d;
4D                     dec ebp;
79 BE                  jns loop_exp_i;
59                     pop ecx; // ecx = n
49                     dec ecx;
49                     dec ecx;
8B E9                  mov ebp, ecx;
BE 06 02 02 22         mov esi, 0x22020206;
83 F9 02               cmp ecx, 2;
73 AE                  jae loop_n;
C6 44 1A 01 00         mov byte ptr [edx + ebx + 1], 0;
                   loop_to_ascii:
80 0C 1A 30            or byte ptr [edx + ebx], '0';
4B                     dec ebx;
                       dec         ebx  
79 F9                  jns loop_to_ascii;
61                     popad;
C3                     ret;
```
The running time for n = 100 is about 4 seconds, and the result is a number with 38416 digits:
23491019577617 (many digits here) ... (many zeros here) 0000000000000000
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 38 bytes
Initial attempt.  
Uses *Chris Hardwick's Formula*.  
Will attempt to golf further and explain when I have time.
```
24©To12!PIÉm7!729®!InI·-4÷mP®IÍn4÷6*m÷
```
[Try it online!](https://tio.run/##yy9OTMpM/f/fyOTQypB8QyPFAM/DnbnmiuZGlofWKXrmeR7armtyeHtuwKF1nod784BMM63cw9v//zc0AAA "05AB1E – Try It Online")
[Answer]
# [Julia 1.0](http://julialang.org/), ~~83~~ 76 bytes
```
n->^(24576*~12,n%2)*3^6*~7(~24)^((m=n-2)n÷4)/24^(m^2÷4*6)
~n=prod(big,1:n)
```
[Try it online!](https://tio.run/##HYxBCoJAFED3nkKC4H8ZzZkmBUEX7TpDNGCm8kO/Mlq08lodoIPZ1Fu9t3n3R0elfK1NvnJYGFD6kCbBIpXgrcJgb1yksCiNBqDPOVTIn7fGndIGeqOcBwl6C@ejHW5wpVbIjHGd6nm0dUUTDQwy/oNeX45AYTFa4rljILHxN6Ia@FnbGY7UnngWfvO7AKFD@GeVyTiKIuEeF1y/ "Julia 1.0 – Try It Online")
Uses Chris Hardwick's Formula. Takes input as Big integer.
Thanks to H.PWiz for -7 bytes
[Answer]
# [Python 2](https://docs.python.org/2/), 72 bytes
```
lambda n:3674160*61600**(n%2)*24**(~-n/2*6)*0xb88d4641131f0**(n*(n-2)/4)
```
[Try it online!](https://tio.run/##HYpBCsIwEADP@oq9CNnF0uw2bEvBn3hJqdGCbkvoQS9@PQZhGOYw22d/rCYlXa7lGV/THMHGTvvA6kmrPJGzkyBJqPVtrBVSJP@ehmEOGpg7Tv@p0gi2AUtaMxgsBjna/ebkDMw4Hg9bXmyH5AzLDw "Python 2 – Try It Online")
Saved 4 bytes by copying `n*(n-2)/4` from [Neil](https://codegolf.stackexchange.com/a/183422/20260).
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 67 bytes
Using Chris Hardwick's Formula.
```
(12!24576)^Mod[#,2]7!729(24!)^⌊#(#-2)/4⌋/24^(6⌊(#-2)^2/4⌋)&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n6Zgq/Bfw9BI0cjE1NxMM843PyVaWcco1lzR3MhSw8hEUTPuUU@XsoayrpGmvsmjnm59I5M4DTOgGFgozggsqKn23yU/OqAoM68kOk9B104hLTovNlZHoTpPR8FIR8HQoDb2PwA "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 81 bytes
Herbert Kociemba's recursive formula. Takes a BigInt as input.
```
f=n=>[1n,3674160n,322252536375n<<27n][--n]||f(--n)*0xb640000n*0xb88d4641131f0n**n
```
[Try it online!](https://tio.run/##FcpNCoMwFATgvad4CxeJ1pI/o6DpRUTQqikt8lK0lIJ69jTOZj6GefXffh2W5/uToRsn761Bc2s4XqQuFNcsQAiRi1xqWeRY16LAtskybPfdktA0Yb@7ViwET5blqLTiXHIbhgS9dQtBMCCwAoTaAGen0pTCFgEMDlc3T9fZPUjXk3jDg4Z3vFmC9OhoFR3@Dw "JavaScript (Node.js) – Try It Online")
---
# [JavaScript (Node.js)](https://nodejs.org), ~~102 98~~ 96 bytes
Chris Hardwick's formula. Takes a BigInt as input.
```
n=>(n&1n?1403325n<<25n:4n)*918540n*0x83629343d3dcd1c00000n**(n*n-n-n>>2n)/24n**(6n*(n*n/4n-~-n))
```
[Try it online!](https://tio.run/##HYrbCoJAAETf/Yp9kNhdMfemaLr2K8qqUchsaEQg9uumzcBwOMyjfbezm@7PVwzf9dtgN9ia4iRxlUZorVJU1T4XA8YLmadGgItPrjNVaKM73blOOnEEnFNwxHvrWoElyhwqw18nBvE3BmPb4CcKYolCSUAqS6Q4KIoYWQJCnMfsx/48@httWhouWNn@DpeBgq0NK4N1@wE "JavaScript (Node.js) – Try It Online")
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~77~~ ~~75~~ 73 bytes
```
n=>0xb88d4641131f0n**(n*(n-2n)/4n)*13824n**n*851558400n**(n%2n)*315n>>14n
```
[Try it online!](https://tio.run/##JcrRCoIwGMXxe5/iuzDYJtamWwxsPoumLgo5C40IxGdfi@Bc/Dn8Hv27X4fl/nyVCOMUvYtwrfxcrR31WStVKy8hBENaWYGfNLhQta10eiGsUcZYLf/mkIColUHbKo3ow0IM5KhCQ6CLIyV/VRSctoxoCFjDPB3ncGNdz/INO0863zwD3zveZHv8Ag "JavaScript (Node.js) – Try It Online") Based on Christopher Mowla's formula. Takes a BigInt as input. Test harness shamelessly stolen from @Arnauld. `0xb88d4641131f0n` is `3246670537110000n` in decimal. Explanation: I started with the last prime exponent and simplified it to `n*(n-2n)/4n` (this is integer division, so I don't need the adjustment for odd numbers). I then examined the other primes to see whether their exponents were related to this value (which I shall refer to as `o`), and found that they were after a fashion, if I allowed the use of the parity of `n` (which I shall refer to as `p`). The formulae for the exponents are as follows:
```
23:       o
19:       o
17:       o
13:       o
11:      2o +   p
 7:      3o +   p +  1
 5:      4o +  2p +  1
 3: 3n + 4o +  3p +  2
 2: 9n + 4o + 14p - 14
```
The powers can then be grouped by exponent so for example `p` is the exponent of `11*7*5**2*3**3*2**14`.
[Answer]
## [Racket](https://racket-lang.org/), ~~151~~ 141 bytes
-7 bytes thanks to fede s.! 
```
(λ(n[e expt])(/(*(e 11771943321600(modulo n 2))3674160(e 620448401733239439360000(floor(/(*(- n 2)n)4))))(e 24(*(floor(/(sqr(- n 2))4))6))))
```
[Try it online!](https://tio.run/##XY1NDsIgEEb3PQWJm8HEyM8I9izGRWOpaURArIl38w5eCaeNLmR2b773zeTudHFTWfkunFleoIHeDWNwLBV4vyAcHHPPNB05bGENjklprWxRayWNEHCN/cNHFpjiXBuLtCTJKIG4RyEteZrsVpNM@uBjzMulzdIJHDkNVRTS8hffb/krzLmZlcIbSHkMkw8M0pz8sa4YK95VbCq29OED "Racket – Try It Online")
The longest answer using Chris Hardwick's Formula :)
[Answer]
# [Python 2](https://docs.python.org/2/), 122 bytes
```
import math
f=math.factorial
x=lambda n:(1,f(7)*729,f(8)*3**7*f(12)*1024)[n-1]if n<4else x(n-2)*24**6*(f(24)/24**6)**(n-2)
```
[Try it online!](https://tio.run/##HYtBDsIgEEX3PQXLmYlVocQaY09iXKCWlKQMBFng6bFl9d/Py4u/vARWtTofQ8rCm7x0dtrnaM07h@TM2pVpNf71MYJvIA8WRqSB6LLRtdFIFqRCUkTyjA/u5dNZwXc9r99ZFOB@l3pLCCwojad2kKipGpPjDAUGxPoH "Python 2 – Try It Online")
Uses the Herbert Kociemba recursive method.
-2 bytes thanks to Herman L
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~39~~ 38 [bytes](https://github.com/DennisMitchell/jelly/Code-page)
I feel like I've missed some golfs, but...
```
12!×⁽^K*Ḃɓ_2×ṭ¥⁸:4×1,6“ð¥‘!¤*:/×“9Ḟɠ’×
```
A monadic Link implementing Chris Hardwick's Formula.
**[Try it online!](https://tio.run/##AU4Asf9qZWxsef//MTIhw5figb1eSyrhuILJk18yw5fhua3CpeKBuDo0w5cxLDbigJzDsMKl4oCYIcKkKjovw5figJw54bieyaDigJnDl////zU "Jelly – Try It Online")** Or see the [test-suite](https://tio.run/##AVQAq/9qZWxsef//MTIhw5figb1eSyrhuILJk18yw5fhua3CpeKBuDo0w5cxLDbigJzDsMKl4oCYIcKkKjovw5figJw54bieyaDigJnDl//Dh@KCrP//MzM "Jelly – Try It Online") (`n=[1..33]`).
[Answer]
## CJam (47 bytes)
```
qi[1_7m!Z6#*_3*Cm!*2D#*]{2-_j24_m!\6#:P/@#*P*}j
```
[Online demo](http://cjam.aditsu.net/#code=qi%5B1_7m!Z6%23*_3*Cm!*2D%23*%5D%7B2-_j24_m!%5C6%23%3AP%2F%40%23*P*%7Dj&input=10)
This implements Herbert Kociemba's recursion from OEIS: $$a(n) = \begin{cases}
1 & \textrm{ if } n \in \{0,1\} \\
7! \times 3^6 & \textrm{ if } n=2 \\
a(n-1) \times 3\times 12!\times 2^{13} & \textrm{ if } n=3 \\
a(n-2) \times \left(\frac{24!}{24^6}\right)^{n-2} \times 24^6 & \textrm{ if } n>3 \end{cases}$$
using CJam's memoised recursion operator `j`. I've ordered the terms in the MathJax block in the same order as in the code to make the correspondence easy to verify for those who read CJam: any further dissection is not going to shed more light.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 43 bytes
```
_2²:4×6*@24
²_Ḥ:4;ḂU
“€ð‘!×⁽^K,1*ÇP×“9Ḟɠ’:Ñ
```
[Try it online!](https://tio.run/##AVMArP9qZWxsef//XzLCsjo0w5c2KkAyNArCsl/huKQ6NDvhuIJVCuKAnOKCrMOw4oCYIcOX4oG9XkssMSrDh1DDl@KAnDnhuJ7JoOKAmTrDkf///zEwMA "Jelly – Try It Online")
[Answer]
# [Icon](https://github.com/gtownsend/icon), ~~125~~ 110 bytes
```
procedure f(n)
q:=1;every q*:=1 to 24
return 11771943321600^(n%2)*5040*3^6*q^(n*(t:=n-2)/4)/24^(6*(t^2/4))
end
```
[Try it online!](https://tio.run/##TY7BCsIwEETP5iv2IiQBabKNLUbyKwFpV@jBTRtSxa@vKb14m3kwvJmGxNs25zTQuGaCp2QlFh/snd6Uv7DomqEkQCcylTUzWNv39ubaFm1nTJR8RqWvxhndxk4vFWhZfOALqsapBl2UXSURa1OCePzTvR4TSyVOh4x9wN1lDYwJPnkqJPdDx@oH "Icon – Try It Online")
[Answer]
# [C (gcc)](https://gcc.gnu.org/) -lgmp, 279 bytes
```
#include "gmp.h"
#define s mpz_init_set_str
#define m(X)mpz_##X
f(int N,m(t)_){m(t)x;m(init)(x);m(init_set_str)(_,N&1?"3LFbOUwC":"1",62);m(mul_si)(_,_,3674160);m(fac_ui)(x,24);m(pow_ui)(x,x,(N*N-2*N)/4);m(mul)(_,_,x);m(set_si)(x,24);N-=2;m(pow_ui)(x,x,6*N*N/4);m(tdiv_q)(_,_,x);}
```
[Try it online!](https://tio.run/##XZFRa8MgFIXf8yvEsKHBbElaMlgpexjsaWRPg8JWJLNJKkSbGdOGlf71ZWrSPEwQ9ZzzXfHKwoqxYfC5ZHW3KwCsRHO3h56/K0ouC9AC0fxQLrmmbWGmVrMl0AZb0/c3Xom41CAjAmlM8dku/Uogy2HU42l7LYERJdlt/AQXry9fb@@nZ/gIY0jSxAZFV9OW2wgli/RhGaeRlcuc0c7IPUmW9twcTtO5JygLsjAJMny/nCqMuLvY3TmDWbhO/tFpYPCR1Dt@pN8zfBnsq0TOpXteripGANvnCgRmf/zYYnD2gBnW5bLpNFiDXB84cna8xStn2y5poIq2q/Wo2H6ZOJlEk3Nyo0ylEsGb9lNC4rhqbBmKCIijOX8FVKE7JUG08i7DEEe/rKzzqh3C2nzjHw "C (gcc) – Try It Online")
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 85 bytes
```
{0xAB4DE800000**($_%2)*3674160*([*] 1..24)**($_*($_-2)div 4)/24**(($_-2)**2 div 4*6)}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJZm@7/aoMLRycTF1cIABLS0NFTiVY00tYzNzE0MzQy0NKK1YhUM9fSMTDTBciCsa6SZklmmYKKpb2QCFISIaGkZKYBFtcw0a/9bc6XlFykY6ekZGihUc3EWJ1YqKKnEK@jaKVSnKajE1ypx1f4HAA "Perl 6 – Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~51~~ ~~48~~ 44 bytes
-4 bytes thanks to H.PWiz
```
÷^*6÷4□-2⁰Π4*^÷4-D⁰□⁰Π24*729*Π7^%2⁰*24576Π12
```
[Try it online!](https://tio.run/##yygtzv7///D2OC2zw9tNHk1bqGv0qHHDuQUmWnFAvq4LkAMUBAsZmWiZG1lqnVtgHqcKUqRlZGJqbnZugaHR////jY0B "Husk – Try It Online")
This is Chris Hardwick's Formula. Also, this is my first husk program, so any tips would be well appreciated.
[Answer]
# [Haskell](https://www.haskell.org/), ~~86~~ ~~85~~ 74 bytes
-1 byte saved thanks to H.PWiz
  
-11 bytes saved thanks to Max Yekhlakov
```
a=24^6
r 2=3674160
r 3=r 2*a*61600
r n=r(n-2)*a*div(product[2..24])a^(n-2)
```
[Try it online!](https://tio.run/##HYxBCoMwEEX3nmKWRjAkY4irOUJPIFoGIzRUo6Ta66djd//9B@/Fn/eyrmXjmIAg7BXAxsfjCfWRYzp1VjCg1taYsTChm3yVAanzvbPeyO5IuOHGC96cKNepRSVXiF@p7OGaz7uBblQ8/WUp1vwA "Haskell – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 92 bytes
```
lambda n:0xab4de800000**(n%2)*3674160*0x83629343d3dcd1c00000**(n*(n-2)/4)/24**((n-2)**2/4*6)
```
[Try it online!](https://tio.run/##PYrBCsIwEETP@hW5CMlSSbJZYi34J17SptWC3ZZQoX59TD04PBgeM8tnfc6Mebjd8ytMbQyCG7OFlmJfmz0Akk@owPkLWW/AbLXzeHXkootdtN3/VTij0qQ0UvGfAaAm8CoPcxL8nsTIIgV@9BIrYa1qjocljbzuWyUGWUrlLw "Python 2 – Try It Online")
[Answer]
[![enter image description here](https://i.stack.imgur.com/MMRSk.png)](https://i.stack.imgur.com/MMRSk.png)
# C++, ~~187 185 180 176 195(there was a bug) 193~~ 175 bytes (with help from ceiling cat)
This uses the GMP C++ wrapper (GNU multi-precision library), and the formula used by @J42161217 (<https://codegolf.stackexchange.com/a/183381/55953>).
Use `g++ -g rubix.cpp -lgmp -lgmpxx` to compile and link
```
#include <gmpxx.h>
#define R return
using z=mpz_class;z p(z a,z b){z c=1;while(b--)c*=a;R c;}z r(z n){if(n==2)R 3674160;if(n==3)R z("pX4dIaR7jDk",62);R r(n-2)*p(24,6)*p(z("ErvSErbeq",62),n-2);}
```
ungolfed, with test code
```
#include <gmpxx.h>
#include <iostream>
mpz_class p(mpz_class a, mpz_class b) // returns a to power of b. Only works for b  = positive integer
{
    mpz_class c=1;
    while(b--)
        c*=a;
    return c;
}
mpz_class r(mpz_class n) // returns the rubix permutations for a cube of size n
{
    if(n==2)
        return 3674160; // 7!*3^6;
    if(n==3)
        return z("pX4dIaR7jDk",62); // 43252003274489856000 = 8!*3^7*12!*2^10
    return r(n-2) * p(24,6) * p(z("ErvSErbeq", 62), n-2);
    // "ErvSErbeq"base 62 = 3246670537110000 = (24!/24^6)        
}    
main()
{
    for(int i=2; i<34; i++)
        std::cout<<i<<'\t'<<r(i) << std::endl;
}
```
<https://tio.run/##PZAxb4MwEIV3foWVDrETqBpARMImWZqha7t0iFQZ4xC3xrg2tJERf73UIVXfcE937zvpdEzrqGZsmu6EYrKvOKkbfbncn3dBb4WqgSsa7d6YpNZiBzR0gIYOlGhwgBUb/H0WksMyihBbFRQb3vVGAYZHB4xnFRr@Rqoo4n2SbdNN9pD7Jtk7uNCvafVEn7fvjx@LMItRbqCKYrTSME7D7OoeOpivl4Mp@eeMhFcAj//3AiJa2xlOm13QUKEgCoYAeJ1aA4XqgChiDARJUl/XazRnXrar8py1fUeIIGR57JaE@AUECLllXFUSB2Mw/bCTpLWdIjm/5ua/>
[Answer]
# TI-BASIC, ~~63~~ 62 [bytes](http://tibasicdev.wikidot.com/one-byte-tokens), (noncompeting)
```
{fPart(.5Ans),1,1,-6}int(4⁻¹{8,4,Ans²-2Ans,(Ans-2)²:prod({9*11!2^15,7!3^6,24!,24}^Ans
```
Expression which takes input as an integer on `Ans`. Implementation of Chris Hardwick's formula. Noncompeting because the hardware it runs on will only store up to 16 decimal places, so the answer will never be 100% accurate.
Explanation:
```
{fPart(.5Ans),1,1,-6}              # the list {(N (mod 2))/2,1,1,-6}
                                   # implicitly multiplied by
int(4⁻¹{8,4,Ans²-2Ans,(Ans-2)²     # the list {2,1,⌊¼(N²-2N)⌋,⌊¼(N-2)²⌋}
:                                  # store this list of the formula's exponents as Ans
     {9*11!2^15,7!3^6,24!,24}      # list of the formula's bases
                             ^Ans  # raised to their exponents
prod(                              # multiplied together
                                   # implicit print
```
]