I have a program that will find the certain ammount of fibonacci numbers. And now i have the question which is the best code for counting time in fibonacci algorithm?
I have to find out how many numbers can my algorithm count in 1 minute?
the code:
//rekursiivne algoritm
public class Fibo {
//Fibonacci rekursiivse algoritmi põhiosa
public static long fib(int n){
if (n <= 2) return 1;//kui arv on väiksem kui kaks, siis tagastatakse "1"
else return fib(n-1) + fib(n-2);
}
public static void main(String[] args) {
int N = Integer.parseInt(args[0]);//sisestus
for(int i=2; i<=N;i++){//tsükkel, mida täidetakse, kuni nõudmised on rahuldatud
System.out.println(i + ": " + fib(i));//väljatrükk
}
}
and the few time counting things i have found in google. So which one suits better or can you give me a general idea where to put it?
I heard from a friend that getMills function isn't really the right one :(
long start = System.currentTimeInMillis();
goat();
long time = System.currentTimeInMillis() - start;
or
System.currentTimeMillis()
Many thanks to whom ever decides to answer