It should work on arrays of the form a + b * i, where a and b are integer scalars, and i is an integer vector. So, if q=: 6 + 7*1 2 5 11 23, applying this function yields (-/ .* % -/ .+)@:(2 2&$) q 7.4 I think you need instead something like Difference’s greatest common divisor, dgcd =: +./@:(2 -~/\ ]) So dgcd q 7
It’s a bit more complicated to recover the factors, 1 2 5 ..., which seem to be required in the Quora problem: (](([-|~)%])dgcd) q 1 2 5 11 23 This works for the original array, too, (](([-|~)%])dgcd) 21 38 55 106 1 2 3 6 And dgcd 21 38 55 106 17 Sorry for any formatting problems - typing on iPad, Mike Please reply to mike_liz....@tiscali.co.uk. Sent from my iPad > On 14 Aug 2018, at 23:18, Jose Mario Quintana <jose.mario.quint...@gmail.com> > wrote: > > (-/ .* % -/ .+)@:(2 2&$)21 38 55 106 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm