Skip to content

EWD249 - 84

"integer k, s, t;
t:= 1 (and further initialization);
repeat s:= "smallest decomposable value larger than t";
       k:= "the number of ways the above minimum is obtained"
       t:= s
until k > 1"

By storing a collection of triples (number pairs with their corresponding s-value), among which each time the pair(s) with minimum s-value exceeding t will occur and adjusting this collection each time t is increased, a program emerges that is orders of magnitude more efficient, t jumping from decomposable value to the next decomposable value. Programming (or problem solving in general?) as the judicious postponement of decisions and commitments!