Advertisement
STANAANDREY

LSD3 10

Oct 14th, 2022
914
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. def ap(n, d):
  2.     if n == 0:
  3.         return True
  4.  
  5.     if n % 10 == d:
  6.         return True
  7.  
  8.     if n // 10 != 0:
  9.         return ap(n // 10, d)
  10.     else:
  11.         return False
  12.  
  13. def cnt_ap(n, d):
  14.     if n == 0:
  15.         return 1
  16.  
  17.     if n // 10 != 0:
  18.         if n % 10 == d:
  19.             return 1 + cnt_ap(n // 10, d)
  20.         else:
  21.             return cnt_ap(n // 10, d)
  22.     else:
  23.         if n % 10 == d:
  24.             return 1
  25.         else:
  26.             return 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement