for(Lo,Hi,Step,Lo) :- Step>0, Lo=0, plus(Lo,Step,V), V= P0 is P * J; P0=P), !, calc_values(Js, S0, P0, Sum, Product). calc_values(Sum, Product) :- % Find the sum and product findall(V, range_value(V), Values), calc_values(Values, 0, 1, Sum, Product).