Number of 1's in smallest repunits
Submissions: 1754   Accuracy:

45.56%

  Difficulty: Easy   Marks: 2

Every number whose unit’s digit is 3 has a repunit as its multiple. A repunit is a number which has only ones. It is of the form (10n – 1)/9. Example: 3 divides 111, 13 divides 111111.

A positive integer N will be given whose unit’s digit is 3. The task is to find the number of 1s in the smallest repunit which is divisible by the given number N.  

Input:
The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consists of a single line containing a positive integer N whose unit’s digit is 3.

Output:
Corresponding to each test case, in a new line, print the number of 1s in the smallest repunit multiple of the number.

Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 107

Example:
Input
2
3
23
Output
3
22

 

** For More Input/Output Examples Use 'Expected Output' option **

Author: Hemang Sarkar


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.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.