A positive integer is said to be an Ecuadorian number if for some m, the sum of the first m of its n digits, m < n, is equal to the sum of all its other digits. Numbers such as 11, 134, 235, 2024 are all Ecuadorian.

What is the largest gap there can be between two consecutive Ecuadorian numbers?

I believe the largest gap is

179

Here is such an example (there may be an earlier example of a similar sized gap):

599,599,910 to 599,600,089

To see why this is the biggest such gap,

We need to look at the last two digits. Let's do a quick example: consider 899900. This is almost Ecuadorian, as the split 89|9900 creates two groups with almost equal digit sum. However, the second group is larger by one, so let's try moving the split over one: 899|900. Since we moved a nine from the second group to the first group, we see the difference between the two groups changed by 18, which is the most it can change. Now the second group is 17 smaller, which is the most it can be. Hence, starting at 00 and counting up, you must hit an Ecuadorian number by 89. Similarly, starting at 99 and counting down, you must hit an Ecuadorian number by 10. Thus the biggest possible gap is starting at 10, counting up past 00, and up to 89.

• I got the exact logic but couldn't find the example with theoretical maximum gap. Nice work! Commented May 9 at 5:33
• I ran a script to find the first solution, and it's indeed 599,599,910. Commented May 11 at 9:54