title: Ruby - divmod is returning the correct value, but i'm not understanding why
body: <p>I am working on the coding kata Roman Numerals defined <a href="http://vimeo.com/channels/katacasts/7253727" rel="nofollow">here</a>. While I have finished it and am not stuck I do have a question that I need help answering.</p>
  
  <p>Here is where my question sits:</p>
  
  <pre><code>class Fixnum
    NUMERALS = [
      ['V', 5], ['IV', 4], ['I', 1]
    ]
    def to_roman
      roman = ""
      number = self
      for key, value in NUMERALS
        count, number = number.divmod(value)
        roman &lt;&lt; (key * count)
      end
      roman
    end
  end
  </code></pre>
  
  <p>When I execute divmod on say the number 5, like so</p>
  
  <pre><code>5.to_roman
  </code></pre>
  
  <p>It returns V. And that makes sense because</p>
  
  <pre><code>5.divmod(5) =&gt; 1, 0
  </code></pre>
  
  <p>But how does this code above not do the same with </p>
  
  <pre><code>5.divmod(1) =&gt; 5, 0
  </code></pre>
  
  <p>So how is it returning V and not IIIII, since it's just appending the key (I) times count (5). Somehow it's obviously correctly returning V instead of IIIII but i'm not sure where that logic is. Any help would be greatly appreciated. Thanks</p>