Description of the Eight Homework Problem

In studying numbers, one comes across notions like `pythagorean triples' (integers, such that x squared plus y squared equals z squared) as well as the idea that any number can be expressed as the sum of four squares. To investigate these notions, it would be useful to have a predicate that can produce all the lists of k integers, for a given k. This is your task. In this discussion, both integers and numbers refer to non-negative integers (0, 1, 2, 3, and so forth).

Details:

Handin Requirements

Reference:

Nothing new in terms of Prolog primitives.

Sample Run:

brown[73]: pprolog Hmwk8.Given.pp         Hmwk8.pp
Welcome to picoProlog
Reading Hmwk8.Given.pp
Reading Hmwk8.pp

# :- pythagorean_triples(X, Y, Z).

X = 3
Y = 4
Z = 5 ? 

X = 6
Y = 8
Z = 10 ? 

X = 5
Y = 12
Z = 13 ? .

yes

# :- sum_of_four_squares(99, W, X, Y, Z).

W = 9
X = 4
Y = 1
Z = 1 ? .

yes

# :- list_of_k_integers(3, X).

X = 0:0:0:nil ? 

X = 1:0:0:nil ? 

X = 0:1:0:nil ? 

X = 0:0:1:nil ? 

X = 2:0:0:nil ? 

X = 1:1:0:nil ? 

X = 1:0:1:nil ? 

X = 0:2:0:nil ? 

X = 0:1:1:nil ? 

X = 0:0:2:nil ? 

X = 3:0:0:nil ? 

X = 2:1:0:nil ? 

X = 2:0:1:nil ? 

X = 1:2:0:nil ? 

X = 1:1:1:nil ? 

X = 1:0:2:nil ? 

X = 0:3:0:nil ? 

X = 0:2:1:nil ? 

X = 0:1:2:nil ? 

X = 0:0:3:nil ? 

X = 4:0:0:nil ? 

X = 3:1:0:nil ? 

X = 3:0:1:nil ? .

yes

# :- ^D

Hints: