Advertisement
advictoriam

Untitled

Jan 11th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1. public class Numbers
  2. {
  3.    /**
  4.       Computes a sum of even integers
  5.       @param a the lower bound (may be odd or even)
  6.       @param b the upper bound (may be odd or even)
  7.       @return the sum of even integers between a and b (inclusive).
  8.    */
  9.    public int evenSum(int a, int b)
  10.    {
  11.       if(a > b){return 0;}
  12.       return (a % 2 == 0) ? a + evenSum(++a, b) : evenSum(++a, b);
  13.    }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement