From bd5b3c31576fe043ab250fd6c9d684aabe954232 Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Mon, 25 Apr 2022 18:45:44 +0200 Subject: Initial commit --- src/Main.java | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 src/Main.java (limited to 'src/Main.java') diff --git a/src/Main.java b/src/Main.java new file mode 100755 index 0000000..fce6be3 --- /dev/null +++ b/src/Main.java @@ -0,0 +1,51 @@ + +public class Main { + + public static void main(String[] args) { + System.out.println(mult(6, 5)); + } + + private static long fakultaet(long z) { + if(z != 0) return z*fakultaet(z-1); + return 1; + } + + private static int fibonacci(int i) { + if(i == 0) return 0; + if(i == 1) return 1; + return fibonacci(i-1) + fibonacci(i-2); + } + + private static int nachfolger(int z) { + return z+1; + } + + private static int sum(int n, int m) { + if(m == 0) return n; + return sum(nachfolger(n), m-1); + } + + private static int mult(int n, int m) { + if(m == 0) return n; + return sum(mult(n, m-1), n); + } + + private static int acker(int x, int y) { + if(x == 0) return y+1; + if(y == 0) return acker(x-1, y); + return acker(x-1, acker(x, y-1)); + } + + private static int ulam(int x) { + if(x == 1) return 1; + if(x > 1) { + if(x%2 == 0) { + return ulam(x/2); + } else { + return ulam((3*x)+1); + } + } + return -1; + } + +} -- cgit v1.2.1