28 lines
751 B
Java
28 lines
751 B
Java
|
import java.util.LinkedList;
|
||
|
|
||
|
/**
|
||
|
* Created by Christian on 10.02.2015.
|
||
|
*/
|
||
|
public class Numbers {
|
||
|
LinkedList<Long> fibonacci = new LinkedList<Long>();
|
||
|
LinkedList<Double> regularRandom = new LinkedList<Double>();
|
||
|
|
||
|
public Numbers() {
|
||
|
fibonacci.add((long) 1);
|
||
|
fibonacci.add((long) 1);
|
||
|
regularRandom.add(Math.random());
|
||
|
}
|
||
|
|
||
|
public long calcFibonacci(int index) {
|
||
|
if (index < fibonacci.size()) return fibonacci.get(index);
|
||
|
else return calcFibonacci(index - 1) + calcFibonacci(index - 2);
|
||
|
}
|
||
|
|
||
|
public double getRegularRandom(int index){
|
||
|
while (regularRandom.size() <= index) {
|
||
|
regularRandom.add(Math.random());
|
||
|
}
|
||
|
return regularRandom.get(index);
|
||
|
}
|
||
|
}
|