From 67224ec1889dd7d481e1069e4bcb40bb52f41c7c Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 12 Apr 2023 12:24:05 +0200 Subject: add simple but complex recursion example --- Info/Rekursion/.gitignore | 1 + Info/Rekursion/Makefile | 15 +++++++++++++++ Info/Rekursion/Rekursion.java | 13 +++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 Info/Rekursion/.gitignore create mode 100644 Info/Rekursion/Makefile create mode 100644 Info/Rekursion/Rekursion.java (limited to 'Info') diff --git a/Info/Rekursion/.gitignore b/Info/Rekursion/.gitignore new file mode 100644 index 00000000..6b468b62 --- /dev/null +++ b/Info/Rekursion/.gitignore @@ -0,0 +1 @@ +*.class diff --git a/Info/Rekursion/Makefile b/Info/Rekursion/Makefile new file mode 100644 index 00000000..e8269b45 --- /dev/null +++ b/Info/Rekursion/Makefile @@ -0,0 +1,15 @@ +.PHONY: run all clean + +SRC := $(wildcard *.java) +OBJ := $(foreach src, $(SRC), $(subst .java,.class,$(src))) + +all: $(OBJ) + +run: all + @java Rekursion + +clean: + rm -f *.class + +%.class: %.java + javac $< diff --git a/Info/Rekursion/Rekursion.java b/Info/Rekursion/Rekursion.java new file mode 100644 index 00000000..cbc1d6b5 --- /dev/null +++ b/Info/Rekursion/Rekursion.java @@ -0,0 +1,13 @@ +class Rekursion { + public static void main(String argv[]) { + get(0); + } + + public static void get(int x) { + if (x == 6) + System.out.println("Code:"); + if (x < 6) + get(x+=2); + System.out.println(x); + } +} -- cgit v1.2.3