title: Ruby- prime number unique and duplicates
body: <p>I'm just learning Ruby :) and Im trying to create a simple prime-number program where <em>all</em> the primes of a number are printed.</p>
  <p>I'm getting errors where the <em>prime and nonprime numbers are mixed up</em>
  (ie: input of 9 will get you all nonprimes).</p>
  <p>I'm sorry for such a beginner question - I'm struggling alot and need some help :)</p>
  <pre><code>puts &quot;Enter a number please &quot;
  num = gets.chomp.to_i
  
  i = 2
  number = 2
  
  while i &lt; num
    if number % i == 0
      prime = false
    end
      i += 1
    end
    if prime == true
      puts &quot;#{number} is prime&quot;
    else
      puts &quot;#{number} is not prime&quot;
    end
    number += 1
  end
  </code></pre>