I am trying to make a function to take the yth power of number n.
(xp 2 3) should print 8. Instead it just prints
2
2
(xp 10 2) should print 100. Instead it just prints
10
10
(xp 100 100) should print a huge number. Instead it just prints
100
100
Why is this?
(defun xp (x y)
(loop while (> 1 y) do
(setf x (* x x))
(setf y (- y 1))) (print x))
That is what I have now. Everytime I run the, the only output is whatever I enter for x, twice. Ex.(xp 2 3) should print 8. Instead it just prints
2
2
(xp 10 2) should print 100. Instead it just prints
10
10
(xp 100 100) should print a huge number. Instead it just prints
100
100
Why is this?