This is supposed to recursively define a function sum(X,Y,Z) meaning X + Y = Z. how could anything be simpler, right?(adsbygoogle = window.adsbygoogle || []).push({});

It's very good at telling that 0+1=1 or 0+2=2, etc. But give it anything other than 0 for the first variable and it's lost. What's wrong?Code (Text):

sum(0,Y,Y).

sum(s(X),Y,s(Z)) :- sum(X,Y,Z).

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Anybody here know prolog?

**Physics Forums | Science Articles, Homework Help, Discussion**