Guest User

Untitled

a guest
May 20th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. public int count8(int n) {
  2. if(n == 0) return 0;
  3. if(n == 8) return 1;
  4. if(n % 10 == 8 && n / 10 % 10 != 8) return 1 + count8(n/10);
  5. if(n % 10 == 8 && n / 10 % 10 == 8) return 2 + count8(n/10);
  6. return 0 + count8(n/10);
  7.  
  8. }
Add Comment
Please, Sign In to add comment