Wonowon Numbers
Time limit1sMemory limit256 MB
Count primes p up to n, except 2 and 5, whose smallest alternating one-zero multiple starting and ending with 1 has exactly p minus 2 digits.
- Level
Medium5 of 10
- Topics
- Number theory, Math
- Solved
- No attempts yet
Problem
A small village in northern Canada is named Wonowon, because it sits at Mile 101 of the Alaska Highway. A travelling mathematician passed through the village and named a family of numbers after it. A wonowon number is a positive integer whose decimal representation starts with 1, ends with 1, and alternates between 1 and 0. The four smallest wonowon numbers are 101, 10101, 1010101 and 101010101, so a wonowon number always has an odd number of digits, at least three.
No wonowon number is divisible by 2 or by 5. Every other prime is conjectured to divide some wonowon number. For example, 3 divides 10101 (), 7 divides 10101 (), and 11 divides 101010101010101010101 ().
Assume the conjecture holds, and let be the number of digits of the smallest wonowon number divisible by the prime . Then , , , , and .
Experiments show that holds for many primes, among them 7, 17 and 19. Given an integer , count the primes with , , and .
Input
The first and only line contains one integer . ()
Output
Print, on one line, the number of primes with , , and .