Skip to content

Instantly share code, notes, and snippets.

@AndrewGuard
Created December 23, 2013 19:25
Show Gist options
  • Select an option

  • Save AndrewGuard/8103082 to your computer and use it in GitHub Desktop.

Select an option

Save AndrewGuard/8103082 to your computer and use it in GitHub Desktop.
def primes(n)
prime_factors = []
until n == 1
2.upto(n) do |factor|
if n % factor == 0
prime_factors << factor
n /= factor
end
end
end
prime_factors.sort
end
p primes(123123123)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment