Олимпиадный тренинг

Задача 38948. Training task - 1


Задача

Темы: ЕГЭ
Let M – the difference (modulo) of two paired natural divisors of an integer not equal to one and the number itself. If the number does not have such divisors, then the M value is considered equal to zero.
Write a program that iterates over integers greater than  1 000 000, in ascending order and searches among them for those that have at least one value of M  such that 0 < M < 1000 . Print the first five found numbers and their corresponding M values. If the number of suitable M values ​​has more than one, then output the M value formed by the difference with the minimum divisor not equal to 1.

Output format: for each of the five such found numbers in a separate line, the number itself is displayed first, then – M value (one space apart). Lines are displayed in ascending order of found numbers.

 
Example
For the number 12, the pair divisors are the numbers:
2 and 6 (M = 4)
3 and 4 (M = 1)
In the answer, you must specify the value M = 4, since the resulting difference is formed with a minimum divisor of 2.