digits =: 24 next =: {{ (<.y)*1+y-<.y }} catseq =: {{ (([: ".'x',~]) % 10x^<:@#) (digits+1){.;":each<.y }} digitsOf =: {{ <. y * 10^x:x }} solve =: {{ lowerBound =. x:2.0 upperBound =. x:2.9 whilst. (digits digitsOf res) ~: (digits digitsOf start) do. start =. -: lowerBound + upperBound res =. catseq <. next^:(i.digits+1) start if. res < start do. upperBound =. start elseif. res > start do. lowerBound =. start end. end. start }} problem751 =: ({.,'.',}.)": digits digitsOf solve ''