This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prime number finder | |
# Usage: 20.primes, 100.primes | |
module GetAllPrimeNumbers | |
def primes | |
# Get all numbers from 0 to the current number as an array | |
nums = (0 .. self).to_a | |
# We know 0 and 1 can't be prime | |
nums[0] = nums[1] = nil |