total_sum:- total_sum(0). total_sum(S):- S > 20, !. total_sum(S):- random(R), T is R + S, write(T), nl, total_sum(T).