Skip to content

Instantly share code, notes, and snippets.

@gavinmyers
gavinmyers / prime.rb
Created May 14, 2012 02:11
Prime Number Calculator in Ruby
#!/usr/bin/env ruby
puts "limit number:"
max = Integer(gets)
primes = []
puts "going from 2 to #{max}"
(2..max).select do |current|
# if current is divisible by any number in the array (that is not itself) it is not prime
isPrime = true
primes.each do |prime|