Created
July 27, 2018 00:19
-
-
Save koskoci/fb6cc898b238ec493a9d992afe132c36 to your computer and use it in GitHub Desktop.
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
require 'prime' | |
class Primer < Prime::EratosthenesSieve | |
def self.call(limit) | |
new.call(limit) | |
end | |
def call(limit) | |
(1..limit).to_a.inject([]) do |arr, n| | |
arr << get_nth_prime(n) | |
arr | |
end | |
end | |
def get_nth_prime(n) | |
super | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Returns the first n prime numbers. Exercise to expose the private instance method
Prime::EratosthenesSieve#get_nth_prime(n)
by subclassing.