Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. We've created the first vectorized Quicksort(googleblog.com ↗)
    10comments
  2. Small Programming Tricks(will-keleher.com ↗)
    116comments
  3. Dream-RSI: Recursive Self-Improvement through Evolving Worlds(arxiv.org ↗)
    41comments
  4. Accurate Models of AMD Matrix Cores(arxiv.org ↗)
    discuss
  5. Mistral X Mozilla: Private, Multilingual AI Browsing(mistral.ai ↗)
    161comments
  6. Tell the speakers that you liked their talks(ohhelloana.blog ↗)
    50comments
  7. Show HN: An e-ink frame that hears birds and draws them as 1800s illustrations(github.com/arnegiacomo ↗)
    226comments
  8. GitHub Is Having Trouble Counting Things(chuckgreenman.com ↗)
    10comments
  9. The Siberian Ice Maiden and the Scythian World(patrickwyman.substack.com ↗)
    discuss
  10. How big are factorials?(thegreenplace.net ↗)
    17comments
  11. Learning Programming in an Age of LLMs(ploeh.dk ↗)
    143comments
  12. Claude Cowork and chat are now one Claude(claude.com ↗)
    148comments
  13. The DeepMind Institute(deepmind.com ↗)
    20comments
  14. Hackers Got Inside a Flock Camera(wired.com ↗)
    171comments
  15. The Google Play app review process now regularly takes longer than a week(gultsch.social ↗)
    287comments
  16. Can we stop with the uptime percentages?(jim-nielsen.com ↗)
    75comments
  17. ER visits for gambling disorders doubled after expanded online gambling market(utoronto.ca ↗)
    62comments
  18. 145 Days of Uptime, 56 TiB of Traffic, One Debian Upgrade(sarah-robin.com ↗)
    discuss
  19. Show HN: How Stale Is Your AI? Release age and training cutoff for 20 models(stale.jock.pl ↗)
    38comments
  20. Kyber (YC W23) Is Hiring a Forward Deployed Engineer(ycombinator.com ↗)
    discuss
  21. Salesforce Global Outage(salesforce.com ↗)
    147comments
  22. Anatomy of a Texture(agentlien.github.io ↗)
    9comments
  23. A warning about 'model welfare'(mustafa-suleyman.ai ↗)
    271comments
  24. This Code Is CRAP (2011)(googleblog.com ↗)
    41comments
  25. Scaling Golang CI by Replacing actions/setup-go(cloudx.ai ↗)
    16comments
  26. Fed hikes rates as inflation worries push up bond yields(reuters.com ↗)
    1comments
  27. Original Sony PlayStation 2 security chip 'broken wide open' after 26 years(tomshardware.com ↗)
    63comments
  28. Show HN: I made a flight simulator, except you're just a passenger(inflightsimulator.com ↗)
    194comments
  29. Introducing System One Models and Jev(typesafe.ai ↗)
    468comments
  30. Why I'm still bearish on LLMs after Navier-Stokes(dank.systems ↗)
    554comments

How big are factorials?

55 pointsby 1d agoeli.thegreenplace.net
17 comments
21h agoHN ↗

Factorial (n) for n > 24 is greater than 10^n.

4h agoHN ↗

Reminds me of: Professor asked us to find the biggest factorial using C programming language. And then using LISP. You can imagine our surprise.

3h agoHN ↗

There is a algorithm call Prime Swing Factorial that can compute large factorials exactly in arbitrary precision math using prime factorization. Like 10000000! in under second depending of how optimized the math library it. Probably like 100x faster than the normal method.

1h agoHN ↗

With Lisp you can use iterative algos and get that under a second too. SBCL can be ridiculously fast; and if you optimize the compilation for integers... the speed gets really close to your solution.

4h agoHN ↗

Stirling's approximation is also used a lot in statistical mechanics, because you often have to calculate logs of state space sizes, which means lots of combinatorics and thus lots of factorials. Plus it's continuous so you can do calculus.

4h agoHN ↗

The author's casual mention of 52! at the opening of the article triggered an OLD webpage that I saw many years ago

https://czep.net/weblog/52cards.html

Anyone know how to determine the age of this page (it's got be at least 20yrs old)

3h agoHN ↗

The main.css file it imports dates itself to March 9 of 2005, and is housed in an "ancient history" section of the website that covers everything before October 26, 2010, so: "sometime between those two years" =P

3h agoHN ↗

Its first appearance on the WayBack Machine is October 13, 2009, which narrows the range somewhat.

3h agoHN ↗

52 cards is the first thing I think of when I think factorials. It's such a great and relatable way to convey the subject to people, plus it usually ends up blowing their minds like it did mine when I first learned of it. Not from this page, but from a YT vid many moons ago.

3h agoHN ↗

It was made during the brief XHTML craze. (And it's also invalid XHTML)

3h agoHN ↗

A quick and dirty approximation of the number of digits in n! is n lg n, which approximates n! from above, via the inequality

  1 * 2 * … * n ≤ n * … * n.

(This approximation should be familiar to many from an algorithmics class.)

For a tighter bound, use n lg n - n/2, or a better approximation of ln 10 in place of 1/2 if you wish. This comes from Stirling's approximation which notes that

  ln n! = n ln n - n + O(ln n).
3h agoHN ↗

(This approximation should be familiar to many from an algorithmics class.)

You need both sides though :)

What makes it interesting for estimating algorithmic complexity is that \log{n!} \in \Theta(n \log n). One side is obvious as you note, the other less so, but there's a famous trick to do both at once:

\log{n!} = \log{\prod_{h=0}^{n} h} = \sum_{h=0}^{n} \log{h}

Therefore,

\int_0^n \log{x} dx \le \log{n!} \le \int_0^n \log{x+1} dx

with both integrals trivial by parts.

3h agoHN ↗

lg(n!) grows roughly as (n lg n). Constants matter, of course, but to that's the rough estimate.

As an aside, if you take numbers from 0 to (n-1) in an array, there are n! configurations, so representing each configuration or differentiating each configuration take n lg n bits. So, in some sense, taking a mapping that's able to differentiate the input state to map to the ordered state takes at least O(n lg n) time, the standard runtime of a basic sorting algorithm.

Any additional assumptions (n larger than maximum element, distribution of elements) helps reduce this.

1h agoHN ↗

I did factorials even under KLISP 23 with cons cells as fake integers:

https://t3x.org/klisp/22/index.html

Dog slow but the old n270 netbook (32 bit) handles big factorials >20 fine, and OFC it's instant under Common Lisp (SBCL) and Scheme (both S9 and Chicken).

1h agoHN ↗

This brings to mind the analysis in Bender & Orszag; they approach this through difference equations (a bit of a lost art in formal mathematics; very 19th-century feel) rather than integration.

Instead of introducing the gamma function, they instead start from the observation that log(F_n) - log(F_n-1) = log(n), so treating this difference as analogous to integration, it says that F_n ~= nlogn + n as the leading asymptotic behavior. This is clear just by substitution and algebra; no calculus necessary (though it helps to "know the answer beforehand").

From there you can treat the error term in this as F_n = n^n * e^n * E_n and plug that into the same relationship (F_n = n * F_n-1) to derive what that error term looks like asymptotically, and end up in the same place that the integration on the OP leads to.

15m agoHN ↗

What's surprising (to many) is that

n! < exp(n log n)