Advertisement
Guest User

Untitled

a guest
May 5th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. public class TryMe {
  2. public static void main(String[] args) {
  3. int a[] = {24, 35, 67, 89, 102, 134, 167, 189, 209, 289, 354, 396, 425};
  4. System.out.println(mystery(a, 13));
  5. int b[] = {35, 67, 89, 105, 135, 179};
  6. System.out.println(mystery(b, 6));
  7. }
  8. public static int mystery(int a[], int size){
  9. if (size == 1)
  10. return a[0];
  11. if (size == 2)
  12. return (a[0] - a[1]) / 2;
  13. int helper[] = new int[a.length];
  14. int k = 0;
  15. for (int j = 1; j < size - 1; j++){
  16. helper[k] = a[j];
  17. k--;
  18. }
  19. return mystery(helper, size - 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement