title: sum of square integers haskell
body: <p>I have this code to work out the sum of squares of integers in the range of m:n</p>
  
  <pre><code>sumsquares :: Integral a=&gt; Int -&gt; Int -&gt; Int -&gt; Int
  sumsquares m n middle
   | m &gt; n = error "First number cannot be bigger than second number"
   |m==n = m*m
   |otherwise = m*m + sumsquares (m+1)n
  </code></pre>
  
  <p>How would i redefine the function sumsquares for this purpose?</p>
  
  <p>If there is more than one number in the range m:n, compute the middle of the range and add the sum of the squares of (m:middle) to sum of the squares (middle+1:n),
  otherwise there is only one number in the range m:n, so m = = n, and the solution is just the square of m. (Note that with this approach the recursion combines two half- solutions: each sub-problem is approximately half in size of the overall problem).</p>