Skip to content

Instantly share code, notes, and snippets.

@reinh
Created May 28, 2010 23:34
Show Gist options
  • Select an option

  • Save reinh/417890 to your computer and use it in GitHub Desktop.

Select an option

Save reinh/417890 to your computer and use it in GitHub Desktop.
class Integer
def factors
n, i, sqi, ret = self, 2, 4, []
while sqi <= n do
n /= i and ret << i while n % i == 0
sqi += 2 * i + 1
i += 1
end
ret << n if n != 1 && n != self
ret
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment