Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. public static int numsinArr(int[] arr, int num, int length)
  2. {
  3. if(length == 1)
  4. {
  5. if(arr[0] == num)
  6. {
  7. return 1;
  8. }
  9.  
  10. else
  11. {
  12. return 0;
  13. }
  14. }
  15.  
  16. else
  17. {
  18. if (arr[length - 1] == num)
  19. {
  20. return numsinArr(arr, num, length - 1) + 1;
  21. }
  22.  
  23. else
  24. {
  25. return numsinArr(arr, num, length - 1);
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement