Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def is_prime?(num)
- (2...num).each do |divisor|
- return false if (num % divisor == 0)
- end
- true
- end
- def largest_prime_factor(max)
- primes = []
- (2...max).each do |num|
- primes << num if is_prime?(num)
- end
- primes[max-1]
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement