x=ARGV[0].to_i def f(n);(n/2).downto(2){|i| yield i if n%i<1};end f(x){|i| begin; f(i){raise}; rescue; next; end puts "#{i} is the largest prime factor of #{x}" exit }