diff options
author | cc-21 | 2022-10-30 04:51:57 +0000 |
---|---|---|
committer | cc-21 | 2022-10-30 04:51:57 +0000 |
commit | 5600e28c47e4e6672c8e93a35aec0957236e1356 (patch) | |
tree | f811bcb62bdc02eb8683e872e5aca30561b52807 /entries | |
parent | 59b31b060d7afffea217a65885bc89ba91b8a933 (diff) |
Add a buggy implementation
Diffstat (limited to 'entries')
-rw-r--r-- | entries/cc-21/lazy_fib.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/entries/cc-21/lazy_fib.java b/entries/cc-21/lazy_fib.java new file mode 100644 index 0000000..3d06152 --- /dev/null +++ b/entries/cc-21/lazy_fib.java @@ -0,0 +1,25 @@ +import java.util.Random; + +public class fib { + public static int lazy_fib_generator(int num) { + if (num == 0 || num == 1) return 1; + return lazy_fib_generator(num - 1) + lazy_fib_generator(num - 2); + } + + public static void lazy_fib_fuzzer(int num_of_trials) { + Random ran = new Random(); + for (int i = 0; i < num_of_trials; i++) { + try { + int val = ran.nextInt(); + System.out.format("Input value: %d \n", val); + lazy_fib_generator(val); + } catch (Throwable t) { + System.out.format("%s This is the price of being lazy!!\n", t); + } + } + } + + public static void main(String[] args) { + lazy_fib_fuzzer(10); + } +} |