Guest User

Untitled

a guest
Feb 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1.  
  2. public class EvenOdd {
  3.  
  4.  
  5. public static void main(String[] args) {
  6.  
  7.  
  8.  
  9. System.out.println(isEven(21));
  10.  
  11.  
  12. }
  13.  
  14. public static boolean isEven(int n){
  15.  
  16. if (n==0) return true;
  17. else return isOdd(n-1);
  18.  
  19. }
  20.  
  21. public static boolean isOdd(int n){
  22.  
  23. if(n==0) return false;
  24. else return isEven(n-1);
  25. }
  26.  
  27. }
Add Comment
Please, Sign In to add comment