title: f# stackoverflow project euler #4
body: <p>I'm working on problem four of <a href="http://projecteuler.net" rel="nofollow noreferrer">Project Euler</a> and am running into a stackoverflow exception.  I'm not asking for help on solving the problem, I'd just like it explained <em>why</em> I am getting a stackoverflow exception.  It's usually because of infinite recursion but I don't believe that is the case this time (if I'm just blind and not seeing it right now please let me know).</p>
  
  <p>Here's the code:</p>
  
  <pre><code>let Euler4 =
  
  let reverse sum =
      let rec loop (n,x) =
          if n = 0
          then
              x
          else
              loop (n/10,(x*10) + (n%10))
  
      loop (sum, 0);
  
  let isPalindrome arg = (arg = (reverse arg));
  
  let findPalindromes (startx,starty) =
      let rec loop (x,y) acc =
          let result = if isPalindrome (x * y) then ((x,y) :: acc) else acc;
          let next = match (x,y) with
              | (x,y) when y = 100 -&gt; (x-1,starty)
              | _ -&gt; (x,y-1)
          if x = 100 then
              result
          else
              loop (next) result
  
      loop (startx,starty) [];
  
  
  let value = (999,999);
  printfn "%A" (findPalindromes value);
  </code></pre>
  
  <p>;</p>