Problem 3
Statement
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
Solution
The code, in Ruby.
class Bignum
def maxFact
a = self
b = 2
m = 0
while b<a+1
if a%b==0
m=b
a/=b
else
b+=1
end
end
return m
end
end
puts 600851475143.maxFact
Answer
6857
SPEAK / ADD YOUR COMMENT
Comments are moderated.
Posts