forbid negafibonacci numbers

master
Selebrator 7 years ago
parent 04699c95fa
commit 8d213feecb

@ -16,6 +16,9 @@ public class FibonacciDynamic extends Fibonacci {
@Override
public long calculate(int n) {
if(n < 0) {
throw new IllegalArgumentException("n must not be negative. Negafibonacci numbers are not supported.");
}
if(memory.containsKey(n)) {
return memory.get(n);
}

@ -15,6 +15,9 @@ public class FibonacciParallelDynamic extends Fibonacci {
@Override
public long calculate(int n) {
if(n < 0) {
throw new IllegalArgumentException("n must not be negative. Negafibonacci numbers are not supported.");
}
if(memory.containsKey(n)) {
return memory.get(n);
}

@ -5,6 +5,9 @@ import provided._12._1.Fibonacci;
public class FibonacciParallelRecursive extends Fibonacci {
@Override
public long calculate(int n) {
if(n < 0) {
throw new IllegalArgumentException("n must not be negative. Negafibonacci numbers are not supported.");
}
if(n == 0 || n == 1) {
return n;
}

@ -5,6 +5,9 @@ import provided._12._1.Fibonacci;
public class FibonacciRecursive extends Fibonacci {
@Override
public long calculate(int n) {
if(n < 0) {
throw new IllegalArgumentException("n must not be negative. Negafibonacci numbers are not supported.");
}
if(n == 0 || n == 1) {
return n;
}

Loading…
Cancel
Save