不要追求绝对的公平,红尘之中没有公平而言,人活一世,难得糊涂。                                           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 Iy
51Testing软件测试网-g;Sx"Kpp7_

Au sb|4O'f#h#j0=begin
C/ou TB`3@0def v(x)
3K6A/} I3d mH-G x0v:N0  math =Math.sqrt(x).ceil
+e Y,NeU!V0  math.downto 2 do |n|
6v#q u PI#tO0      if x % n ==0 && v(n)==1
sIjL(f0         return n
xwx5gwT0     end
$jx!NUx O9p B#c0  end51Testing软件测试网7J7q8~SZ;`
  151Testing软件测试网4E{h[M/bv[9[Px
end
_Y9Eh&m-t-r$uP ]%P0p v(600851475143) #6857
{-i2z4?l\*YWk(S9G0=end

TAG:

 

评分:0

我来说两句

Open Toolbar