Semi-prime H-numbers
Time limit1sMemory limit128 MB
For each H-number h, count H-semi-primes up to h, where H-primes are irreducible among numbers of the form 4n+1.
- Level
Medium6 of 10
- Topics
- Number theory, Math, Prefix sum, Brute force
- Solved
- No attempts yet
Problem
This problem is based on an exercise proposed by David Hilbert, who suggested studying the theory of numbers of the form . Here we explore only a small part of it.
An H-number is a positive integer that is one more than a multiple of four: are the H-numbers. For this problem we pretend that these are the only numbers. The H-numbers are closed under multiplication.
Just as with the ordinary integers, we partition the H-numbers into units, H-primes, and H-composites. is the only unit. An H-number is an H-prime if it is not the unit and can be written as a product of two H-numbers in exactly one way, namely . All remaining H-numbers are H-composites.
For example, the first few H-composites are , , , , and .
Your task is to count the H-semi-primes. An H-semi-prime is an H-number that is the product of exactly two H-primes; the two H-primes may be equal or different. In the example above, all five numbers are H-semi-primes. By contrast, is not an H-semi-prime, because it is the product of three H-primes.
Input
Each line contains an H-number with . The final line contains and must not be processed.
Output
For each input H-number , print a single line containing and the number of H-semi-primes between and inclusive, separated by a single space.