summer(Start, End, 0) :- Start == End.
summer(Start, End, Sum) :-
    Start \== End,
    Next is Start + 1,
    summer(Next, End, Rest),
    Sum is Start + Rest.

my_sum :-
    write('Enter start: '),
    read(Start),
    write('Enter end: '),
    read(End),
    summer(Start, End, Sum),
    write('The sum is: '),
    write(Sum), nl.

summer_main :-
    Start = 1, End = 9,
    summer(Start, End, Sum),
    write('The sum of '), write(Start), write(' to '), write(End), write(' is: '), write(Sum), nl.

:- initialization(summer_main).
