We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I have reached the next solution in common lisp, but the last test keeps failing with wrong result. I cannot undestand why, I have tested locally and the result seems to be the expected, and the performance is also good.
Can anyone explain me what is the problem?
Pentagonal Numbers
You are viewing a single comment's thread. Return to all comments →
I have reached the next solution in common lisp, but the last test keeps failing with wrong result. I cannot undestand why, I have tested locally and the result seems to be the expected, and the performance is also good. Can anyone explain me what is the problem?
(defun sumpent (n) (if (< n 2) 1 (+ (memopent (1- n)) (- (* 3 n) 2))))
(let ((npast (make-hash-table))) (defun memopent (n) (let ((currval (gethash n npast))) (if currval currval (setf (gethash n npast) (sumpent n))))))
(let ((n (read))) (loop for line from 0 below n do (format t "~a~%" (memopent (read)))))