Write Two Clauses Prolog Determines Three Values List Sum Value N Output Single True Exist Q37106017

Write two clauses in PROLOG that determines if there are threevalues in a list that sum up to a value of N.

The output should be a single true if there exist three valueswhose sum is N or a single false if there are not.

If there are multiple values whose sum is N then the programshould only print true once.


Solution


Program screenshots:

% declare the predicate. sumValues([],A):-false. sumValues ([Q|X],A) :- [W|X1]=X, % Append the values. append([Q],x1,x2), % s

Sample output:

sum Values([7, 1, 10, 3, 8, 2],9). IG Singleton variables: [A] true

Code to copy:

% declare

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.