Created
December 1, 2013 15:51
-
-
Save khacanh/7735565 to your computer and use it in GitHub Desktop.
Divisors
This file contains 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
class Fixnum | |
def divisors | |
ceil = Math.sqrt(self).ceil | |
(1..ceil).select {|i| self % i == 0 } | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
so, if you assign a numerical value now to a variable 't', you should be able to call the divisors method
t = 2
puts 2.divisors