If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.
{20,48,52}, {24,45,51}, {30,40,50}
For which value of p  1000, is the number of solutions maximised?
My Solution
(defun Euler39(n)
  (let ((maxnum 0)
	         (currentnum 0)
	         (pNum 0))
    (loop for i from 10 to n
	             for j=0
	             do (progn (setq currentnum (loop for k from 1 to (floor (/ i 3))
		    	                                                     when (integerp (/ (- (expt i 2) (* 2 k i))
					                                                                                     (- (* 2 i) k)))
			                                                          sum 1))
(if (> currentnum maxnum)
(progn (setq maxnum currentnum)
                                            (setq pNum i)))))
    pNum))
 
No comments:
Post a Comment