# Pastebin bjEhb1sU def is_prime(x) if x < 2 return false end if x == 2 return true end (2..Math.sqrt(x).sqrt.ceil + 1).each do |i| if x % i == 0 return false end end true end num = 600851475143 max = 0; i = 2; while i <= num if num % i == 0 && is_prime(i) puts "#{i} is a prime factor" num /= i; if i > max max = i end i = 2; end i += 1 end puts "Largest prime factor: #{max}"