From 6fd882f53fd698d1983a814d3e8fea95d33743ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DNyymix=E2=80=9D?= Date: Fri, 29 Apr 2022 10:25:41 +0300 Subject: [PATCH] Add Java version --- Fibo.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Fibo.java diff --git a/Fibo.java b/Fibo.java new file mode 100644 index 0000000..a9c8093 --- /dev/null +++ b/Fibo.java @@ -0,0 +1,20 @@ + public class Fibo + { + static final int count = 40; + + private static long fibo(int i){ + if (i < 3) + return 1; + else + return fibo(i-1) + fibo(i-2); + } + + public static void main(String[] args) { + System.out.println("Lasketaan fibo: " + count); + long before = System.currentTimeMillis(); + for (int i=1; i <= count; i++) + System.out.println("Fibo: " + i + " = " + fibo(i)); + long after = System.currentTimeMillis(); + System.out.println("Laskenta kesti: " + (after - before) + " ms"); + } + } \ No newline at end of file