Реферат: Логические задачи на языке программирования Prolog
Sum=Number+Partial_sum.
Результат: Сумма ряда : 55
domains
number,sum=integer
predicates
sum(number,sum)
goal
write(“Суммаряда : “),
sum(2,sum), write(sum).
clauses
sum(18,0).
sum(Number, Sum) :--
New_number=Number+2,
sum(New_number,Partial_sum),
Sum=Number+Partial_sum.
Результат: Сумма ряда : 72
domains
number,sum=integer
predicates
sum(number,sum)
goal
write(“Суммаряда : “),
sum(9,sum), write(sum).
clauses
sum(0,11).
sum(Number, Sum) :--
New_number=Number-1,
sum(New_number,Partial_sum),
Sum=Number+Partial_sum