pythagoreantree/src/Numbers.java
Jan Christian Grünhage dfd1841e2f PythagorasTree impementation, not working
New pythagoras Tree implementation, not fully working yet
2015-02-10 17:51:44 +01:00

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);
}
}