I\'m trying to create a program in Prolog which takes two numbers - A and B and finds the sum of the numbers from A to B, including them.
To sum up: sum(1, 5, C) should
Available in SWI-Prolog, library(aggregate) is a full fledged interface:
?- aggregate(sum(N), between(1,5,N), S). S = 15.
it does internally a similar work as you can read in Kaarel' answer. Anyway, to learn Prolog, follow C.B. detailed explanation.