Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def ap(n, d):
- if n == 0:
- return True
- if n % 10 == d:
- return True
- if n // 10 != 0:
- return ap(n // 10, d)
- else:
- return False
- def cnt_ap(n, d):
- if n == 0:
- return 1
- if n // 10 != 0:
- if n % 10 == d:
- return 1 + cnt_ap(n // 10, d)
- else:
- return cnt_ap(n // 10, d)
- else:
- if n % 10 == d:
- return 1
- else:
- return 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement