@@ -0,0 +1,2513 @@
+%0Aimport java.util.*;%0A%0Apublic class Serveur implements Interface%0A%7B%0A    private HashMap %3CInteger,Double%3E fibo_results;%0A    private int number;%0A    private boolean fast_mode;%0A    private boolean cache_mode;%0A%0A    // Constructor%0A    public Serveur()%0A    %7B%0A        this(false, false);%0A    %7D%0A%0A    public Serveur(boolean fast_and_cache)%0A    %7B%0A        this(fast_and_cache, fast_and_cache);%0A    %7D%0A%0A    public Serveur(boolean fast, boolean cache)%0A    %7B%0A        fast_mode = fast;%0A        cache_mode = cache && fast;%0A%0A        fibo_results = new HashMap %3CInteger, Double%3E ();%0A%0A        number = 1;%0A%0A        // known values%0A        ajout_result(0,0);%0A        ajout_result(1,1);%0A    %7D%0A%0A    private void ajout_result(int n, double result)%0A    %7B%0A        fibo_results.put(new Integer(n), new Double(result));%0A    %7D%0A%0A    // implements %22Interface%22%0A    public double fibonacci(int n)%0A    %7B%0A        if (n %3C= 0)%0A            return 0;%0A%0A        if (fast_mode)%0A            if (cache_mode)%0A                return loop_cached_fibonaci(n);%0A            else%0A                return loop_fibonacci(n);%0A        else%0A            return rec_fibonacci(n);%0A    %7D%0A%0A    // recursive based algorithm, complexity = 2%5En%0A    private double rec_fibonacci(int n)%0A    %7B%0A        if (n %3C= 1)%0A            return n;%0A        else%0A            return rec_fibonacci(n-1) + rec_fibonacci(n-2);%0A    %7D%0A%0A    // loop based algorithm, complexity =~ 2*n%0A    private double loop_fibonacci(int n)%0A    %7B%0A        if (n == 1 %7C%7C n == 2)%0A        %7B%0A            return 1;%0A        %7D%0A%0A        double fibo1=1, fibo2=1, result=1;%0A%0A        for (int i = 3; i %3C= n; i++)%0A        %7B%0A            result = fibo1 + fibo2; //Fibonacci number is sum of previous two Fibonacci number%0A            fibo1 = fibo2;%0A            fibo2 = result;%0A%0A        %7D%0A        return result;%0A    %7D%0A%0A    // loop based algorithm with result caching, complexity =%3C %22loop_fibonacci%22%0A    private double loop_cached_fibonaci(int n)%0A    %7B%0A        if (n %3C= number) // == fibo_results.contains(n)%0A            return fibo_results.get(n);%0A%0A        double fibo1 = fibo_results.get(number-1);%0A        double fibo2 = fibo_results.get(number);%0A        double result = 0;%0A%0A        for (int i = number + 1; i %3C= n; i++)%0A        %7B%0A            // calculation details :%0A            //~ System.out.println(i + %22 : %22 + fibo1 + %22 + %22 + fibo2 + %22 %3E %22 + result);%0A%0A            result = fibo1 + fibo2;%0A            fibo1 = fibo2;%0A            fibo2 = result;%0A%0A            ajout_result(number = i, result);%0A        %7D%0A%0A        return result;%0A    %7D%0A%7D%0A

Create Serveur.java