不要追求绝对的公平,红尘之中没有公平而言,人活一世,难得糊涂。
it is no use doing what you like, you have got to like what you do.
Problem 3
上一篇 /
下一篇 2009-09-08 10:24:24
/ 个人分类:projecteuler题目 ruby实现
# Problem 3
H1_\/L{6^c6D*L4p0#The prime factors of 13195 are 5, 7, 13 and 29.
~zc)F)}0#What is the largest prime factor of the number 600851475143 ?
51Testing软件测试网"R{C0Rr
Iy51Testing软件测试网-g;Sx"Kpp7_Au sb|4O'f#h#j0=begin
C/ou
TB`3@0def v(x)
3K6A/}
I3d mH-Gx0v:N0 math =Math.sqrt(x).ceil
+e
Y,NeU!V0 math.downto 2 do |n|
6v#q uPI#tO0 if x % n ==0 && v(n)==1
sIjL(f0 return n
xwx5g wT0 end
$jx!NUx
O9pB#c0 end
51Testing软件测试网7J7q8~SZ;` 1
51Testing软件测试网4E {h[ M/bv[9[Pxend
_Y9Eh&m-t-r$uP]%P0p v(600851475143) #6857
{-i2z4?l\*YWk(S9G0=end
收藏
举报
TAG: