commit 701d32c0217dd392561aec5b310cedac6fe29def Author: Sobottasgithub Date: Wed Nov 12 21:19:54 2025 +0100 Init diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..f5bd2df --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..495801a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Fakultaet.java b/Fakultaet.java new file mode 100644 index 0000000..f1b32bd --- /dev/null +++ b/Fakultaet.java @@ -0,0 +1,27 @@ +public class Fakultaet { + public Fakultaet() { + int inputNum = 30; + System.out.println("Iterativ: " + iterativFakultaet(inputNum)); + System.out.println("Recursiv: " + recursivFakultaet(inputNum)); + } + + public Fakultaet(int num) { + System.out.println("Iterativ: " + iterativFakultaet(num)); + System.out.println("Recursiv: " + recursivFakultaet(num)); + } + + public int iterativFakultaet(int num) { + int result = 1; + for (int index = 1; index <= num; index++) { + result = index * result; + } + return result; + } + + public int recursivFakultaet(int num) { + if (num == 1) { + return num; + } + return num * recursivFakultaet(num-1); + } +} diff --git a/Main.java b/Main.java new file mode 100755 index 0000000..3582b96 --- /dev/null +++ b/Main.java @@ -0,0 +1,6 @@ +public class Main { + public static void main(String[] args) { + //Fakultaet fakultaet = new Fakultaet(30); + Rekursion rekursion = new Rekursion(); + } +} diff --git a/Rekursion.java b/Rekursion.java new file mode 100644 index 0000000..226c3ca --- /dev/null +++ b/Rekursion.java @@ -0,0 +1,51 @@ +public class Rekursion { + public Rekursion() { + System.out.println(fibonacci(10)); + System.out.println(fibonacciIterativ(10)); + System.out.println("Result " + mystery(5)); + } + + public int fibonacci(int n) { + if (n == 0) { + return 0; + } else if (n == 1) { + return 1; + } else { + return fibonacci(n-1) + fibonacci(n-2); + } + } + + public int fibonacciIterativ(int n) { + if (n == 0) { + return 0; + } else if (n == 1) { + return 1; + } + + int next = 0; + + int a = 1; + int b = 0; + + for (int index = 0; index < n; index++) { + next = a + b; + a = b; + b = next; + } + + return next; + } + + public int mystery(int n) { + System.out.println(n); + if (n <= 1) { + return 1; + } + + return n + mystery(n-1); + } + + private static String getString(int binaryNum) { + return String.valueOf(binaryNum); + } +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..dc0a060 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1760948891, + "narHash": "sha256-TmWcdiUUaWk8J4lpjzu4gCGxWY6/Ok7mOK4fIFfBuU4=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "864599284fc7c0ba6357ed89ed5e2cd5040f0c04", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1761114652, + "narHash": "sha256-f/QCJM/YhrV/lavyCVz8iU3rlZun6d+dAiC3H+CDle4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "01f116e4df6a15f4ccdffb1bcd41096869fb385c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1754788789, + "narHash": "sha256-x2rJ+Ovzq0sCMpgfgGaaqgBSwY+LST+WbZ6TytnT9Rk=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "a73b9c743612e4244d865a2fdee11865283c04e6", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b814942 --- /dev/null +++ b/flake.nix @@ -0,0 +1,57 @@ +{ + description = "Inventar"; + + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + ]; + systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ]; + perSystem = { config, self', inputs', pkgs, system, ... }: let + + jdk = pkgs.jdk21.override { + }; + + buildInputs = [ + jdk + ]; + + devTools = [ + pkgs.google-java-format + ]; + + in { + devShells.default = pkgs.mkShell { + buildInputs = buildInputs ++ devTools; + }; + + packages = { + default = pkgs.stdenv.mkDerivation { + pname = "recursiveFakultaet"; + version = "1.0.0"; + + src = ./.; + + nativeBuildInputs = buildInputs ++ [ pkgs.makeWrapper ]; + + buildPhase = '' + javac -Werror -g:none -deprecation -verbose Main.java + ''; + + installPhase = '' + mkdir -p $out/{bin,lib} + cp *.class $out/lib + + makeWrapper ${pkgs.lib.getExe jdk} $out/bin/recursiveFakultaet --add-flags "-cp $out/lib/ Main" + ''; + }; + }; + }; + flake = { + }; + }; +} diff --git a/out/production/recursivFakultaet/.envrc b/out/production/recursivFakultaet/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/out/production/recursivFakultaet/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/out/production/recursivFakultaet/.idea/.gitignore b/out/production/recursivFakultaet/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/out/production/recursivFakultaet/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/out/production/recursivFakultaet/.idea/misc.xml b/out/production/recursivFakultaet/.idea/misc.xml new file mode 100644 index 0000000..f5bd2df --- /dev/null +++ b/out/production/recursivFakultaet/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/recursivFakultaet/.idea/modules.xml b/out/production/recursivFakultaet/.idea/modules.xml new file mode 100644 index 0000000..495801a --- /dev/null +++ b/out/production/recursivFakultaet/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/out/production/recursivFakultaet/Fakultaet.class b/out/production/recursivFakultaet/Fakultaet.class new file mode 100644 index 0000000..719a758 Binary files /dev/null and b/out/production/recursivFakultaet/Fakultaet.class differ diff --git a/out/production/recursivFakultaet/Main.class b/out/production/recursivFakultaet/Main.class new file mode 100644 index 0000000..1cbb4dd Binary files /dev/null and b/out/production/recursivFakultaet/Main.class differ diff --git a/out/production/recursivFakultaet/Rekursion.class b/out/production/recursivFakultaet/Rekursion.class new file mode 100644 index 0000000..e9f1c52 Binary files /dev/null and b/out/production/recursivFakultaet/Rekursion.class differ diff --git a/out/production/recursivFakultaet/flake.lock b/out/production/recursivFakultaet/flake.lock new file mode 100644 index 0000000..dc0a060 --- /dev/null +++ b/out/production/recursivFakultaet/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1760948891, + "narHash": "sha256-TmWcdiUUaWk8J4lpjzu4gCGxWY6/Ok7mOK4fIFfBuU4=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "864599284fc7c0ba6357ed89ed5e2cd5040f0c04", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1761114652, + "narHash": "sha256-f/QCJM/YhrV/lavyCVz8iU3rlZun6d+dAiC3H+CDle4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "01f116e4df6a15f4ccdffb1bcd41096869fb385c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1754788789, + "narHash": "sha256-x2rJ+Ovzq0sCMpgfgGaaqgBSwY+LST+WbZ6TytnT9Rk=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "a73b9c743612e4244d865a2fdee11865283c04e6", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/out/production/recursivFakultaet/flake.nix b/out/production/recursivFakultaet/flake.nix new file mode 100644 index 0000000..b814942 --- /dev/null +++ b/out/production/recursivFakultaet/flake.nix @@ -0,0 +1,57 @@ +{ + description = "Inventar"; + + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + ]; + systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ]; + perSystem = { config, self', inputs', pkgs, system, ... }: let + + jdk = pkgs.jdk21.override { + }; + + buildInputs = [ + jdk + ]; + + devTools = [ + pkgs.google-java-format + ]; + + in { + devShells.default = pkgs.mkShell { + buildInputs = buildInputs ++ devTools; + }; + + packages = { + default = pkgs.stdenv.mkDerivation { + pname = "recursiveFakultaet"; + version = "1.0.0"; + + src = ./.; + + nativeBuildInputs = buildInputs ++ [ pkgs.makeWrapper ]; + + buildPhase = '' + javac -Werror -g:none -deprecation -verbose Main.java + ''; + + installPhase = '' + mkdir -p $out/{bin,lib} + cp *.class $out/lib + + makeWrapper ${pkgs.lib.getExe jdk} $out/bin/recursiveFakultaet --add-flags "-cp $out/lib/ Main" + ''; + }; + }; + }; + flake = { + }; + }; +} diff --git a/out/production/recursivFakultaet/recursivFakultaet.iml b/out/production/recursivFakultaet/recursivFakultaet.iml new file mode 100644 index 0000000..b107a2d --- /dev/null +++ b/out/production/recursivFakultaet/recursivFakultaet.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/recursivFakultaet.iml b/recursivFakultaet.iml new file mode 100644 index 0000000..b107a2d --- /dev/null +++ b/recursivFakultaet.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file