From 4b48621b48d3248b5e2718a10e35e7276c504a72 Mon Sep 17 00:00:00 2001 From: Paul Jungeblut Date: Sun, 22 Oct 2017 19:48:13 +0200 Subject: Adding code for Möbius Inversion. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- math/mobius.cpp | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 math/mobius.cpp (limited to 'math/mobius.cpp') diff --git a/math/mobius.cpp b/math/mobius.cpp new file mode 100644 index 0000000..7830eb1 --- /dev/null +++ b/math/mobius.cpp @@ -0,0 +1,4 @@ +// Laufzeit: O(N*log(log(N))) +int mu[N+1]; mu[1] = 1; +for (int i = 1; i <= N; i++) { + for (int j = 2 * i; j <= N; j += i) mu[j] -= mu[i]; -- cgit v1.2.3