From ccacaa9af82ea74c7ad2b3518d4d3bb3012ae80c Mon Sep 17 00:00:00 2001 From: E7-87-83 Date: Mon, 11 Apr 2022 02:16:15 +0800 Subject: Task 2 Java Solution --- challenge-159/java/Moebius.java | 79 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 challenge-159/java/Moebius.java (limited to 'challenge-159/java') diff --git a/challenge-159/java/Moebius.java b/challenge-159/java/Moebius.java new file mode 100644 index 0000000000..b52e049ca8 --- /dev/null +++ b/challenge-159/java/Moebius.java @@ -0,0 +1,79 @@ +// The Weekly Challenge 159 +// Task 2 Moebius Function +// Usage: java Moebius N + +public class Moebius +{ + public static void main(String[] args) + { + int N = 1; + try { + N = Integer.parseInt(args[0]); + } catch (Exception e) { + System.err.print("Please use a positive integer "); + System.err.println("as your parameter."); + System.exit(0); + } + double[][] complex1 = new double[][] { {1, 0} , {0, 1} }; + double[][] complex2 = new double[][] { {0, 1} , {-1, 0} }; + System.out.println(Math.round(mu(N))); + } + + + public static double mu(int n) + { + double[][] sum = ithRootOfUnityModuloN(1, n); + LOOP: for (int i=2; i