Problem 1068
In this country, all numbers are positive integers whose digits (in decimal digits) are different from 0.At each number of n digits, we associate its (n − 1) "descendants":
- its son, formed by all the figures of its father except the leftmost one
- its grand-son, formed by all the figure of its grand-father except the two leftmost ones
- and so on...
A number is "refined" when it is a multiple of its son.
- 1. What is the greatest refined number so that all of its descendants of at least two figures are refined? (6 points)
A number is said "elegant" when it is a multiple of its grand-son.
- 2. What is the greatest elegant number so that all of its descendants of at least three figures are elegant? (6 points)
For this problem, python is more convenient because of the necessary conversions between strings and integers. The idea is the same for both questions: if we remove numbers to the left of a number checking the condition of the question, it also checks the question; so we can build the numbers in this way (iteratively). The idea is thus to maintain a list of the numbers to be examined, and to test whether the concatenation of a digit on the left always verifies the condition, in which case the number is added to the list of elements to be explored (two lists are used in practice). When there is no more number in the list, it means that one has indeed explored all the numbers checking the constraint.
The code is available here.
The code is available here.
- 1. 95 625
- 2. 81 421 875