title: Ruby - determine if a number is a prime
body: <p>I'm running through the problems on <a href="http://projecteuler.net" rel="noreferrer">Project Euler</a> to teach myself Ruby programming.  <em>I know there is a built-in function to do this</em>, but I'm avoiding the built-in functions to help me learn.</p>
  
  <p>So I have to write a method to determine if a number is a prime.  The first method works, but the second doesn't.  Can anyone explain why?</p>
  
  <pre><code> def is_prime n
    for d in 2..(n - 1)
     if (n % d) == 0
      return false
     end
    end
  
    true
   end
  
   def is_prime2 n
    foundDivider = false
     for d in 2..(n - 1)
      foundDivider = ((n % d) == 0) or foundDivider
     end
    not foundDivider
   end
  </code></pre>