Q3. Define a predicate to output the values of the squares of the integer from N1 to N2 inclusive and test it with N1=6 and N2=12
Code :
predicates
testloop(integer)
clauses
testloop(5).
testloop(N):-N>=6,write("square of "),write(N),write(" is "),N1=N*N,write(N1),nl,M=N-1,testloop(M).
Goal
testloop(12).
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment