Class: Prime
- Inherits:
-
Object
- Object
- Prime
- Defined in:
- lib/vru_prime.rb
Instance Method Summary collapse
Instance Method Details
#sample ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/vru_prime.rb', line 2 def sample puts"enter the first number" num=gets.to_i puts"enter the range" last=gets.to_i while (num <= last) prime_flag = true x = 2 while (x <= num / 2) if (num % x == 0) prime_flag = false break end x += 1 end if prime_flag puts""+num.to_s end num += 1 end end |