We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Implementation
  4. Find Digits

Find Digits

Problem
Submissions
Leaderboard
Discussions
Editorial
Topics

An integer is a divisor of an integer if the remainder of .

Given an integer, for each digit that makes up the integer determine whether it is a divisor. Count the number of divisors occurring within the integer.

Example

Check whether , and are divisors of . All 3 numbers divide evenly into so return .

Check whether , , and are divisors of . All 3 numbers divide evenly into so return .

Check whether and are divisors of . is, but is not. Return .

Function Description

Complete the findDigits function in the editor below.

findDigits has the following parameter(s):

  • int n: the value to analyze

Returns

  • int: the number of digits in that are divisors of

Input Format

The first line is an integer, , the number of test cases.
The subsequent lines each contain an integer, .

Constraints


Sample Input

2
12
1012

Sample Output

2
3

Explanation

The number is broken into two digits, and . When is divided by either of those two digits, the remainder is so they are both divisors.

The number is broken into four digits, , , , and . is evenly divisible by its digits , , and , but it is not divisible by as division by zero is undefined.

Author

HackerRank

Difficulty

Easy

Max Score

25

Submitted By

293806

Need Help?


View discussions
View editorial
View top submissions
RESOURCES

  • Div Mod
  • Integer to Array

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy