Given a number N, the task is to count all the digits in N which divide N. Divisibility by 0 is not allowed. If any digit in N which is repeated divides N, then all repetitions of that digit should be counted

**Input:**

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains the integer N.

**Output:**

Print the count of all digits of n which divide n for each test case in a new line.

**Constraints:**

1<= T <=100

1<= No of digits in N <=10^{5}

**Example:**

**Input:**

2

35

122324

**Output:**

1

5

**Explanation:**

For testcase 1: N=35. Now, 3 does not completely divide 35, but 5 does; so our count is 1.

For testcase 2: N=122324. Here, 1 divides N. 2 divides N. Again, 2 divides N. 3 does not divide N. 2 divides N. 4 divides N. So, total number of digits that divide N are 5.

Author: sujnesh

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

tushki | 198 |

namansharmacse17 | 110 |

TusharMittal3 | 70 |

adkeaesph | 57 |

deepakchoudhary11 | 48 |

ARUN_PUNDIR | 720 |

manishgupta8497 | 623 |

AMAN__JAIN | 596 |

Abhimanyu_kumar | 562 |

Bicky_Shokeen | 532 |

blackshadows | 5335 |

Ibrahim Nash | 5223 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4584 |

Login to report an issue on this page.