TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Decomposing a Factorial into Large Factors

139 pointsby surprisetalkabout 2 months ago

7 comments

SJC_Hackerabout 2 months ago
Edit: as pointed out, you can&#x27;t simply divide by each number, because then its not equal to original number factorial. However, I&#x27;ve fixed the algorithm somewhat maintaining the basic idea<p>The &quot;naive&quot; way<p><pre><code> 100!= 2*3*4*...*99*100 </code></pre> Obviously t(100) &gt; 1. If we can get rid of the single 2, we know that t(100) &gt; 2. If you multiply the whole thing by 2&#x2F;2 (=1),<p><pre><code> 100! = (2&#x2F;2)*2*3*4*...*50*...99*100 = (2*2&#x2F;2)*3*4*...*50*...99*100 = (4&#x2F;2)*3*4*...*50*...99*100 = 4*3*4*...*50*...99*(100&#x2F;2) = 3*4*4*...*50*50*...99 </code></pre> We can continue with t(100) &gt; 3 by multiplying by 3&#x2F;3 and pairing it with 99, i.e. 99*3*(3&#x2F;3) = (99&#x2F;3)*3*3 = 33*9 yielding<p><pre><code> 100! = 4*4*5*...*9*9*10*..*33*33*...*50*50...*97*98 </code></pre> However, once we get to t(100) &gt; 4, trying to get rid of 4, we have to skip 98 since its not divisible by 4. The other problem is we have two 4s... If we had instead using 98 for getting rid of 2, we can then use 100, and 96 for the other 4. This is our first &quot;gotcha&quot; for the naive algorithm of always picking the largest number, which seems intuitive at first glance.<p>Now if we test all possibilities starting with 2, we get 48 choices for the dividing 2 (even numbers &gt; 2, not including 2 which will not increase t(100) beyond 2. Then ~33 choices for dividing 3 (depending if our div of 2 resulted in a factor of 3), ~25 for 4, But notice since we now have two 4s, we have to do it twice, so its 25*24 choices for getting rid of 4.*
评论 #43508738 未加载
评论 #43508968 未加载
btillyabout 2 months ago
Out of curiosity, I wondered how tight these bounds are. Consider the case of 300,000 which Terry has put a lower bound of 90,000 on, and would like a bound of 100,000 on. If a perfect division of factors into equal buckets could be achieved, the answer would be 110366.49020484093 per bucket. That&#x27;s e^(log(n!)&#x2F;n), to within the precision that Python calculates it. (My first try was to use Stirling&#x27;s formula. That estimated it at 110366.49020476094, which is pretty darned close!)<p>A straightforward greedy approach will see those final buckets differing by factors of around 2. Which is a lot worse than Terry&#x27;s current approach.<p>This really is a knapsack problem.
评论 #43517727 未加载
评论 #43507207 未加载
dvhabout 2 months ago
As a kid I was bugged by the fact that Stirling formula doesn&#x27;t give exact integer result, so I set to find my own formula. I failed, but discovered that sum from 1 to N is (n*n+n)&#x2F;2. Surely if perfect formula for sum exists, for multiplication should exist too.
评论 #43508548 未加载
phkahlerabout 2 months ago
Is there a standard notation for the product of all even numbers up to N and for the product of all odd numbers up to N? I know if N is even then the product of evens is = (N&#x2F;2)! * 2^(N&#x2F;2) so I guess notation for that is a little redundant, but there is no simple formula for the product of the odd numbers.
评论 #43509238 未加载
评论 #43509488 未加载
评论 #43509240 未加载
kevinventulloabout 2 months ago
Has anyone tried throwing a math-specialized LLM at this? I’m only half joking.
评论 #43512941 未加载
zahlmanabout 2 months ago
From comments:<p>&gt;No; in fact, in Guy’s article on this problem, he notes that there is a jump of 2 from t(124)=35 to t(125)=37<p>Huh. Can we actually prove t(N) is monotonic? Jumps like that seem like they could be one-offs in some cases.
评论 #43507685 未加载
tempodoxabout 2 months ago
I&#x27;m still confused as to how to compute t(N). Maybe it&#x27;s buried in the legalese of this text and I&#x27;m just dumb, but I can&#x27;t find a clue.
评论 #43508025 未加载
评论 #43507925 未加载
评论 #43507987 未加载