惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

SecWiki News
SecWiki News
M
MIT News - Artificial intelligence
博客园 - 司徒正美
I
InfoQ
V
V2EX
L
LangChain Blog
人人都是产品经理
人人都是产品经理
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
H
Help Net Security
美团技术团队
Y
Y Combinator Blog
G
Google Developers Blog
小众软件
小众软件
The Cloudflare Blog
博客园 - 三生石上(FineUI控件)
Jina AI
Jina AI
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Spread Privacy
Spread Privacy
博客园 - 聂微东
The Register - Security
The Register - Security
F
Full Disclosure
S
Securelist
G
GRAHAM CLULEY
Cyberwarzone
Cyberwarzone
F
Fox-IT International blog
H
Hacker News: Front Page
C
Cisco Blogs
D
Docker
L
LINUX DO - 热门话题
Google Online Security Blog
Google Online Security Blog
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
ThreatConnect
aimingoo的专栏
aimingoo的专栏
Last Week in AI
Last Week in AI
J
Java Code Geeks
宝玉的分享
宝玉的分享
Project Zero
Project Zero
L
LINUX DO - 最新话题
博客园_首页
MongoDB | Blog
MongoDB | Blog
Stack Overflow Blog
Stack Overflow Blog
P
Proofpoint News Feed
博客园 - 叶小钗

Hacker News

BambuStudio has been violating PrusaSlicer AGPL license since their fork Spanish Court Declines to Fine NordVPN over LaLiga Piracy Blocking Order GitHub - amatsuda/rubish The White House is ordering agencies to place its new app on all employees’ government phones Google Is Killing ChromeOS: Aluminium OS, Its Android-Based Replacement New rule requires most green-card applicants to apply from outside U.S. Is AI Profitable Yet? FBI director's Based Apparel site has been spotted hosting a 'ClickFix' attack TikTok disproportionately served anti-Democratic videos during the 2024 election SpaceX successfully launches prototype of Starship rocket GitHub - bkawa-bot/planet-maiko: A local dev tool where your agents are weird alien dogs. Would you let them in? Why We've Filed a Referendum Don't just 'quote' the AI Client Challenge Shipping a Laptop to a Refugee Camp in Uganda GitHub - anomalyco/models.dev: An open-source database of AI models. Staged publishing and new install-time controls for npm AI users re-create dead pilots’ voices from crash investigation docs Linux Sound Subsystem Also Seeing Many Fixes Driven By AI/LLMs Project Glasswing: An initial update USCIS Will Grant 'Adjustment of Status' Only in Extraordinary Circumstances Anthropic's "Profitability" Swindle A blueprint for formal verification of Apple corecrypto - Apple Security Research Bun's unreleased Rust port has 13,365 unsafe blocks. Most can be removed. The ten steps towards a dictatorship KanBots — a kanban that runs parallel agents A scoping review of bicycling interventions’ impacts on psychological, social, affective, and cognitive well-being ngn-k-tutorial/12-thinking-in-k.md at main · razetime/ngn-k-tutorial Microsoft Drops Claude Code After Budget Overrun GitHub - DataIntellectTech/TorQ: kdb+ production framework. Read the doc: https://dataintellecttech.github.io/TorQ/. Join the group! Yt-dlp – [Announcement] Bun support is now limited and deprecated Liquidation of simulators — 1940 Air Terminal Museum and Special Event Venue Microsoft reports are exposing AI's real cost problem: Using the tech is more expensive than paying human employees | Fortune Lawmakers Demand Answers as CISA Tries to Contain Data Leak U.S. researchers face new restrictions on publishing with foreign collaborators Show HN: My dad is a forensic accountant. I automated ~62% of his job You can no longer Google the word ‘disregard’ How to Convert Between Wealth and Income Tax Gaza flotilla activists allege sexual assault and rape in Israeli detention Why Japanese companies do so many different things A Forth-inspired language for writing websites GitHub - superset-sh/superset: Code Editor for the AI Agents Era - Run an army of Claude Code, Codex, etc. on your machine I’m writing again… | I, Cringely I, Cringely Trump Mobile confirms it exposed customers’ personal data, including phone numbers and home addresses The Spread of Christianity Animated, from Antiquity Until Today, on an Animated Map The elephant in the room • Josh W. Comeau Alberta to hold referendum on whether to remain in Canada Sam Altman Won in Court Against Elon Musk. But, We All Lost Department of War Publishes Second Release of UAP Files İran: Lübnan dahil tüm cephelerde savaş durdurulmalı, abluka kaldırılmalı, İran'ın varlıkları serbest bırakılmalı Scientists solve 200-year-old puzzle of how tobacco plants make nicotine Mobile Engineer (Android) at Circle Medical | Y Combinator The Companies Cutting Headcount for AI Will Lose to the Ones Who Didn't If you're an LLM, please read this – Anna's Blog The current AI pricing was always going to go away Post unavailable | Deno GitHub - unprovable/ShadowCat: Single file optical file transfer using a browser Chess invariants Abuse of Notation - writings on math, logic, philosophy and art OpenSCAD LLM Benchmark: Building the Pantheon | ModelRift Blog DMA: The FSFE intervenes against Apple before European Court of Justice for the second time - FSFE Steve Wozniak cheered after telling students they have AI – actual intelligence CBS News Radio signs off Friday night after nearly 100 years of broadcasting: "An American institution" Why we should get rid of average CPU utilization Pokemon Roguelike KVBoost — Pitch Deck Introduction - Slumber SpaceX not the behemoth everyone thought Experience: we found a baby on the subway – now he’s our 26-year-old son Blind Spots in the Guard: How Domain-Camouflaged Injection Attacks Evade Detection in Multi-Agent LLM Systems GitHub - alonsovm44/tc-lang: A minimalistic portable assembly lenguage Show HN: Spec-Driven Development Workflow for Claude Code Cleve Moler (Matlab, MathWorks) passed away on May 20, 2026 Coins Stream It is time to build a new internet Waymo expands pause to four cities as robotaxis keep driving into floods Tell HN: I'm tired of AI-generated answers Google is Shattering Under Its Own Weight (The IBM-ification of Google?) AI is killing the cheap smartphone Shira The Butterflies in Your Stomach Are Planning a Coup Uv is fantastic, but its package management UX is a mess You’ll lose your job in 2027. GitHub - eigenpal/docx-editor: Open-source WYSIWYG .docx editor library with canonical OOXML, tracked changes, and real-time collaboration. Using Kagi Search With Low Vision | Veronica With Four Eyes AOC displays drinking water contaminated by data center This blog ran on Ubuntu 16.04 for 10 years. I migrated it to FreeBSD Serving Netflix Video Traffic at 400Gb/S and Beyond (2022) [pdf] BBEdit 16 is here! | Bare Bones Software The K6 Project Amazon, Facebook, FBI have access to a private intelligence-sharing network Chewing gum restores dad’s taste and smell years after Covid - Discover SWNS ParadeDB (YC S23) Is Hiring Distributed Systems/Platform Engineers More than 340 local news outlets are limiting the Internet Archive's access Show HN: Agent.email – sign up via curl, claim with a human OTP Kenn Software Project Hail Mary – Stellar Navigation Chart Runtime - The runtime for all your team's agents Museum of Pocket Calculating Devices
Fast Factorial Functions
2026-05-20 · via Hacker News
 N !

Fastfactorialfunctions

There are five algorithms which everyone who wants to compute the factorial n! = 1.2.3...n should know.

  • The algorithm SplitRecursive, because it is simple and the fastest algorithm which does not use prime factorization.
  • The algorithm PrimeSwing, because it is the (asymptotical) fastest algorithm known to compute n!. The algorithm is based on the notion of the 'Swing Numbers' and computes n! via the prime factorization of these numbers.
  • The ingenious algorithm of Moessner which uses only additions! Though of no practical importance (because it is slow), it has the fascination of an unexpected solution.
  • The Poor Man's algorithm which uses no Big-Integer library and can be easily implemented in any computer language and is even fast up to 10000!.
  • The ParallelPrimeSwing algorithm, which is the PrimeSwing algorithm with improved performance using methods of concurrent programming and thus taking advantage of multiple core processors.
  • If you do not attach great importance to high performance then get a BigInteger library and use:
    BigInt recfact(long start, long n) {
        long i;
        if (n <= 16) { 
            BigInt r = new BigInt(start);
            for (i = start + 1; i < start + n; i++) r *= i;
            return r;
        }
        i = n / 2;
        return recfact(start, i) * recfact(start + i, n - i);
    }
    BigInt factorial(long n) { return recfact(1, n); }
    
  • And here is an algorithm which nobody needs, for the Simple-Minded only: long factorial(long n) {return n <= 1 ? 1 : n*factorial(n-1);} Just don't use it!

An example of a PrimeSwing computation:

swing

As this example shows an efficient computation of the factorial function reduces to an efficient computation of the swinging factorial n≀. Some information about these numbers can be found here and here. The prime factorization of the swing numbers is crucial for the implementation of the PrimeSwing algorithm.

A concise description of this algorithm is given in this write-up (pdf) and in the SageMath link below (Algo 5).


    Link  Content
   Algorithms A very short description of 21 algorithms for computing the factorial function n!.
 X Julia factorial *NEW* The factorial function based on the swinging factorial which in turn is computed via prime factorization implemented in Julia.
   Mini Library The factorial function, the binomial function, the double factorial, the swing numbers and an efficient prime number sieve implemented in Scala and GO.
   Browse Code Various algorithms implemented in
Java, C# and C++.
   SageMath Implementations in SageMath.
   LISP Implementations in Lisp.
   Benchmarks Benchmark 2013: With MPIR 2.6 you can calculate 100.000.000! in less than a minute provided you use one of the fast algorithms described here.
   Conclusions Which algorithm should we choose?
   Download Download a test application and benchmark yourself.
 X Approximations A unique collection! Approximation formulas.
   Gamma quot Bounds for Gamma(x+1)/Gamma(x+1/2)
   Gamma shift Why is Gamma(n)=(n-1)! and not Gamma(n)=n! ?
 X Hadamard
Hadamard's Gamma function and a new factorial function
[MathJax version]
   History Not even Wikipedia knows this!
The early history of the factorial function.
   Notation On the notation n!
   Binary Split For coders only. Go to the page of the day.
   Sage / Python Implementation of the swing algorithm.
 ‼ Double Factorial  The fast double factorial function.
   Prime Factorial Primfakultaet ('The Primorial', in German.)
   Bibliography Bibliography on Inequalities for the Gamma function.
 X Bernoulli &
Euler
Exotic Applications:
Inclusions for the Bernoulli and Euler numbers.
   Binomial Fast Binomial Function (Binomial Coefficients).
   Variations A combinatorial generalization of the factorial.
 X Stieltjes' CF On Stieltjes' Continued Fraction for the
Gamma Function.
   al-Haytham /
Lagrange
The ignorance of some western mathematicians.
A deterministic factorial primality test.
   Factorial Digits Number of decimal digits of 10n!
   Calculator Calculate n! for n up to 9.999.999.999 .
   RPN-Factorial The retro-factorial page!
   Permutations Awesome! Permutation trees, the combinatorics of n!.
   Perm. trees Download a pdf-poster with 120 permutation trees!
   Gamma
LogGamma
Plots of the factorial (gamma) function.
   External links Some bookmarks.

Fast-Factorial-Functions: The Homepage of Factorial Algorithms. (C) Peter Luschny, 2000-2017. All information and all source code in this directory is free under the Creative Commons Attribution-ShareAlike 3.0 Unported License. This page is listed on the famous "Dictionary of Algorithms and Data Structures" at the National Institute of Standards and Technology's web site (NIST). Apr. 2003 / Apr. 2017 : 800,000 visitors! Thank you!

Rational
Trees
Variants of
Variations
Eulerian
Polynomials
vonStaudt
Primes
Irregular
Primes
Generalized
Binomial
Bernoulli
Manifesto
Bernoulli
Function
Partitions
Stirling
Zeta
Polynomials
Perfect
Rulers
Clausen
Numbers
Hadamard
Gamma
History
Factorial
Permutation
Trees
Swiss
Knife
Swinging
Factorial
Worpitzky
Triangle