Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Numbers
- {
- /**
- Computes a sum of even integers
- @param a the lower bound (may be odd or even)
- @param b the upper bound (may be odd or even)
- @return the sum of even integers between a and b (inclusive).
- */
- public int evenSum(int a, int b)
- {
- if(a > b){return 0;}
- return (a % 2 == 0) ? a + evenSum(++a, b) : evenSum(++a, b);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement