@Cowsquack "so I would say the apl/j solution actually has an advantage in this regard, ie more memory efficient" -- there's no doubt your solution is the better, deeper solution. my only point is that it's less "simple", and that (tacit) J seems to have trouble expressing a class of simple procedural problems that are trivially expressed with a while loop and a 2 or more temporary, mutating variables. These types of problems don't seem amenable to "array thinking", despite their simplicity.