I have a code to get list of prime numbers:
def primes_numbers num primes = [2] 3.step(Math.sqrt(num) + 1, 2) do |i| is_prime = true
You can list prime numbers like this as well.
Example Array: ar = (2..30).to_a ar.select{ |n| (2..n).count{ |d| (n % d).zero? } == 1 }