A Multiple Made Only of Ones
InterviewTime limit1sMemory limit128 MB
Given n not divisible by 2 or 5, find the number of digits of the smallest repunit (all ones) that n divides.
- Level
Medium5 of 10
- Topics
- Number theory, Math, Implementation, Hash map
- Solved
- No attempts yet
Problem
You are given an integer () that is divisible by neither nor . Among the numbers whose digits are all (that is, , , , ), you want to find one that is a multiple of . Because is not a multiple of or , such a number always exists.
Input
The input consists of several test cases. Each test case is a single line containing one integer , and the input continues until end of file.
Output
For each test case, print on its own line the number of digits of the smallest multiple of whose digits are all .