Advertisement
korobushk

count8

Mar 31st, 2021
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.20 KB | None | 0 0
  1. public int count8(int n) {
  2.     int count = 0;
  3.   if(n<8)
  4.   return 0;
  5.   if(n%100==88) {
  6.     count =2;
  7.   }else if(n%10==8){
  8.     count =1;
  9.   }else{
  10.     count = 0 ;
  11.   }
  12.   return count+count8(n/10);
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement