Advertisement
PhilHole

Fibo sum of operations

Sep 10th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. public BigInteger iterativeF(int n) {
  2. BigInteger a = BigInteger.ONE;
  3. BigInteger b = BigInteger.ZERO;
  4.  
  5. for (int i = 0; i < n; i++) {
  6. b = b.add(a);
  7. a = b.subtract(a);
  8. }
  9. return b;
  10. }
  11.  
  12. public BigInteger sumOfOperations(BigInteger lastFiboNumber) {
  13. return BigInteger.ONE.add(lastFiboNumber).divide(BigInteger.TWO).multiply(BigInteger.valueOf(5));
  14.  
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement