title: factorial algorithm in pseudo code
body: <p>I've been given the following algorithm, that takes a positive integer <em>K</em> and returns a value:</p>
  
  <pre><code>X = 1
  Y = 1
  while X ≠ K do
      X = X + 1
      Y = Y * x
  return Y
  </code></pre>
  
  <p>I'm supposed to figure out what it returns.</p>
  
  <p>As it happens, I know the answer &mdash; it returns the factorial of <em>K</em> &mdash; but I don't understand why.</p>
  
  <p>How do you go about figuring out what this pseudocode does?</p>