/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
}
static ArrayList<Double> getSeries(int n)
{
ArrayList<Double> series = new ArrayList<>();
series.add(0.0); // This is working as replacement of the F(0)
series.add(1.0); // This is working as replacement of the F(1)
double x, y;
for (int i = 1; i < n; i++)
{
x = series.get(i - 1); // This is working as replacement of the F(n-2)
y = series.get(i); // This is working as replacement of the F(n-1)
series.add(x + y);
}
return series;
}
}
Standard input is empty
[0.0, 1.0, 1.0, 2.0, 3.0, 5.0, 8.0, 13.0, 21.0, 34.0, 55.0, 89.0, 144.0, 233.0, 377.0, 610.0, 987.0, 1597.0, 2584.0, 4181.0, 6765.0, 10946.0, 17711.0, 28657.0, 46368.0, 75025.0, 121393.0, 196418.0, 317811.0, 514229.0, 832040.0, 1346269.0, 2178309.0, 3524578.0, 5702887.0, 9227465.0, 1.4930352E7, 2.4157817E7, 3.9088169E7, 6.3245986E7, 1.02334155E8, 1.65580141E8, 2.67914296E8, 4.33494437E8, 7.01408733E8, 1.13490317E9, 1.836311903E9, 2.971215073E9, 4.807526976E9, 7.778742049E9, 1.2586269025E10]