SHARE
TWEET

Untitled

advictoriam Jan 11th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top