This attempt yields the error: *** Read error: The input could not be tokenized at 2, 2. ***
> (defun sum (n1 n2)
“Returns the sum of two positive integers.”
(assert
(and (integerp n1) (>= n1 0))
(n1)
“N1 must be a nonnegative integer, instead it’s ~S.”
(n1)...
Would it be something like this?
(defun nsum (n)
(if (integerp n)
(if (or (= n 0) (< n 1))
Please enter the positive integer
(* n(/ 2(+ n 1))))))
Regards
Help! Please
I am trying to write a Lisp program to calculate the sum of the first N positive integers where, for example, when N = 6 the sum of the first N = 21
Any Ideas?
A friend of mine is really pulling my chain. He said the answer to this was right in front of me. I doubt that! Does anyone have an idea on this?
"I have a bar of chocolate 6 blocks wide by 9 blocks long and I want to split it into its individual blocks making the smallest number of breaks...