PixUnit

AdHoc-Add

Apr 27th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.30 KB | None | 0 0
  1. /**
  2.  * Created by Nenad on 27.04.2016.
  3.  */
  4. public class add {
  5.  
  6.     private static int add(int a, int b){
  7.        
  8.         a = b == 0 ? a :( b < 0 ? add(--a, ++b) : add(++a,--b));
  9.         return a;
  10.     }
  11.  
  12.     public static void main(String[] args) {
  13.         System.out.println(add(1,11));
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment