LeetCode solutions

2608. Count the Digits That Divide a Number

My accepted Python solution to LeetCode problem 2608, Count the Digits That Divide a Number, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 12.3MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 12.3MB, accepted 2025-12-24.

python
class Solution(object):
    def countDigits(self, num):
        count = 0
        n = num
        while n > 0:
            digit = n % 10
            if num % digit == 0:
                count += 1
            n //= 10
        return count

Source