Overview

 

Question

The prime factors of 13195 are 5, 7, 13 and 29.

What is the largest prime factor of the number 600851475143 ?

click for answer

6857

Solutions

 

Ruby

 prime-factor.rb https://raw.github.com/addamh/euler/master/003/prime-factor.rb download
#!/usr/bin/env ruby
require 'mathn'
p 600851475143.prime_division.last[0]
$ time ruby prime-factor.rb
real	0m0.046s
user	0m0.040s
sys	0m0.005s