Count the Digits That Divide a Number

EasyMath

Solution

export function countDigits(num: number): number {
  let answer = 0;
  let current = num;
  while (0 < current) {
    const value = current % 10;
    if (num % value === 0) {
      answer += 1;
    }
    current = Math.floor(current / 10);
  }
  return answer;
}