Skip to content

Instantly share code, notes, and snippets.

@kunalbhatt
Created October 2, 2012 05:46
Show Gist options
  • Select an option

  • Save kunalbhatt/3816456 to your computer and use it in GitHub Desktop.

Select an option

Save kunalbhatt/3816456 to your computer and use it in GitHub Desktop.
Primes Review
def primes(num)
primes = [ ]
(2..num).each do |divider|
until num % divider != 0
if num % divider == 0
primes << divider
num = num/divider
end
end
end
primes
end
def primes num
while num == 1
(2..num).each do |divider|
original = num
if num > 0 and divider = num-1 and num % divider == 0
primes << divider
num = num/divider
end
end
end
puts primes(81).inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment