Prolog recursive logic : I'm trying to implement a method to work as follows  foo(5) = 5^4 + 4^3 + 3^2 + 2^1 + 1^0 = 701 using recursion. I've been trying to follow the logic but I keep getting errors. can someone guide me?


    (define (foo  n) ; size-n problem
    ( cond ( (= (- n 1) 0 ) ; stopping condition
       0 ); return value
    (else (+ ( expt  n  (- n 1) ) ( foo (- n 1) ) ) ))) ; size-m problems
