top | item 39584633

(no title)

shiftingleft | 2 years ago

> Shouldn't be too hard to do even with pen and paper since the 2-adic eval of 52! is large.

Could you elaborate?

discuss

order

Y_Y|2 years ago

https://en.wikipedia.org/wiki/P-adic_valuation

It's nothing fancy, get the prime power decomposition of your number and pick the exponent of p.

There's a clever way to do that for a factorial, but I have the Pari/GP app on my phone so I just did:

    valuation(52!,2)
which gives the answer 49, so 52! is divisible by 2 forty-nine times. Interestingly chatgpt4 turbo got it right with no extra prodding needed.

johnp314|2 years ago

One can do this mentally easily enough. 52! = 525150....321, and there are 26 even numbers in this progression, so we have 26 powers of 2. Taking them out, there are 13 of those even factors divisible by 4, but we already took out the first 2 from each so we have 13 more 2's, giving 26 + 13 = 39. Now on to factors divisible by 8, they are half of those that are divisible by 4, so half of 13, giving 6 more 2's (52 is not divisible by 8 so we round down). Thus so far we have 39 + 6 = 45 two's in the factorization of 52!. On to numbers less than 52 that are divisible by 16, that's half those divisible by 8, so 3 more, getting us to 48. Finally there is there is the factor 32 = 2^5 of 52! giving us one more 2, hence 49. i.e. for p a prime, the largest k such that p^k divides n! is given by k = Floor(n/p) + Floor(n/p^2) + ... + Floor(n/p^t) where p^(t+1)>n

theamk|2 years ago

Does not seem right, the number is way too low.. after all, just the last factor (52) can be divided by 2 at least 5 times.

My calculator says 225 bits, and text suggests the same. Looks like chatgpt4 was wrong as usual:)

qsort|2 years ago

The basic method would be to assign a number, 0 through 52!-1, to each permutation in lexicographic order. Because 52! is not a power of 2, if you want to encode binary bits, you can only use 2^N permutations, where that number is the largest power of 2 less than 52!. You can not losslessly encode more than N bits, that's a hard bound, they just won't fit.

If you wanted to turn this into an actual protocol, you would presumably flag some permutations as invalid and use the other ones. You would then encode one bit at a time doing a binary search of the set of valid permutations.

Because 52! has a large number of 2s in its factorization, for a careful choice of the valid permutations it should be practical (or at least not significantly more impractical than the OP's proposed method) to perform this by hand because you would be able to "eyeball" most splits of the binary search.