Skip to content

Instantly share code, notes, and snippets.

@khacanh
Created December 1, 2013 15:51
Show Gist options
  • Save khacanh/7735565 to your computer and use it in GitHub Desktop.
Save khacanh/7735565 to your computer and use it in GitHub Desktop.
Divisors
class Fixnum
def divisors
ceil = Math.sqrt(self).ceil
(1..ceil).select {|i| self % i == 0 }
end
end
@gholadr
Copy link

gholadr commented Dec 2, 2013

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment