package praktikum1; import java.util.*; public class Fibonacci2 { static HashMap vastused = new HashMap<>(); public static long f(int n) { if (vastused.containsKey(n)) { return vastused.get(n); } if (n == 0) { return 0; } if (n == 1) { return 1; } vastused.put(n, f(n - 1) + f(n - 2)); return vastused.get(n); } public static void main(String[] args) { for (int i = 0; i < 100; i++) { System.out.println(f(i) + " "); } } }