Guest User

Untitled

a guest
May 9th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. public class Fibonacci {
  2.     public static void main(String[] args) {
  3.         long timeStart = System.currentTimeMillis();
  4.         long result = 0;
  5.         for (int i = 0; i < 100_000; i++) {
  6.             result = fib(24);
  7.         }
  8.         long timeStop = System.currentTimeMillis();
  9.         System.out.println("result: " + result + ", time: " + (timeStop - timeStart));
  10.     }
  11.  
  12.     public static long fib(int n) {
  13.         if (n <= 1) return n;
  14.         else return fib(n - 1) + fib(n - 2);
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment