=begin The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 317584931803? =end def isPrime(i) print 'Prime? '+i.to_s+"\n" 2.upto Math.sqrt(i).floor do |j| return false if (i % j) == 0 end true end n = 317584931803 2.upto((n / 7).floor) do |i| qt = (n / i.to_f) if qt == qt.truncate && isPrime(qt) print qt.to_s exit end end