Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1. private static int oddSum(final int left, final int right) {
  2.         if (right<=left)
  3.             return 0;
  4.         if (right % 2 == 0)
  5.             return oddSum(left+1,right);
  6.         else
  7.             return oddSum(left+1,right)+1;
  8.         }
  9.  
  10.     // just for testing ...
  11.     public static void main(String[] args) {
  12.         System.out.println(oddSum(2,5));
  13.         // Den Rumpf dieser Methode können Sie ohne Auswirkung auf die Korrektheit der Lösung beliebig verändern.
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement