Because `9 / 25 - 6 / 17 gt 1 / 142 , ` we can guarantee a fraction with the denominator 142. But it is too long to iterate over all values from 1 to 142 to find the smallest.
Let a fraction be `m / n , ` then we need `6 / 17 lt m / n lt 9 / 25 . ` In other words, `( 17 m ) / 6 gt n gt ( 25 m ) / 9 .`
Let's iterate over m (the numerator) starting from 1. Because 9/25 and 6/17 are near 1/3, the values of m will be about three times less than of n, and we'll be able to iterate less.
For m=1 it gives `17 / 6 gt n gt 25 / 9 ` or `2.aaa gt n gt 2.ddd, ` which is impossible.
For m=2 it gives `34 / 6 gt n gt 50 / 9 ` or `5.aaa gt n gt 5.ddd, ` which is impossible.
For m=3 it gives `51 / 6 gt n gt 75 / 9 ` or `8.aaa gt n gt 8.ddd, ` which is impossible.
For m=4 it gives `68 / 6 gt n gt 100 / 9 ` or `11.aaa gt n gt 11.ddd, ` which is impossible.
For m=5 it gives `85 / 6 gt n gt 125 / 9 ` or `14.aaa gt n gt 13.ddd, ` which is possible for n=14.
The required fraction is 5/14 and the minimum value of the denominator is 14.