FR | EN
Quentin L. Meunier
Associate Professor in Computer Science at Sorbonne Université

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":
A number is "refined" when it is a multiple of its son.


A number is said "elegant" when it is a multiple of its grand-son.





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.




  • 1. 95 625

  • 2. 81 421 875