Clean code
This commit is contained in:
parent
92ec140860
commit
790b07679c
1 changed files with 4 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
|
// Fibonacci number generator in Java using recursion
|
||||||
public class Fibo
|
public class Fibo
|
||||||
{
|
{
|
||||||
static final int count = 40;
|
static final int COUNT = 40;
|
||||||
|
|
||||||
private static long fibo(int i){
|
private static long fibo(int i){
|
||||||
if (i < 3)
|
if (i < 3)
|
||||||
|
@ -10,9 +11,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("Lasketaan fibo: " + count);
|
System.out.println("Lasketaan fibo: " + COUNT);
|
||||||
long before = System.currentTimeMillis();
|
long before = System.currentTimeMillis();
|
||||||
for (int i=1; i <= count; i++)
|
for (int i=1; i <= COUNT; i++)
|
||||||
System.out.println("Fibo: " + i + " = " + fibo(i));
|
System.out.println("Fibo: " + i + " = " + fibo(i));
|
||||||
long after = System.currentTimeMillis();
|
long after = System.currentTimeMillis();
|
||||||
System.out.println("Laskenta kesti: " + (after - before) + " ms");
|
System.out.println("Laskenta kesti: " + (after - before) + " ms");
|
||||||
|
|
Loading…
Reference in a new issue