不要追求绝对的公平,红尘之中没有公平而言,人活一世,难得糊涂。                                           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
.g#D \9I |,JB%Co'{a0#The prime factors of 13195 are 5, 7, 13 and 29.51Testing软件测试网t Tx5S8ig!hH
#What is the largest prime factor of the number 600851475143 ?
|Z0@O J3y"tMb051Testing软件测试网 S-nwd;O [

S8x{7I7OD(S0=begin
8rlOI3\r(a:W g8e0def v(x)
,^;b~-l:r-fs5\F0  math =Math.sqrt(x).ceil
bQ]+QO9C-U#f0  math.downto 2 do |n|51Testing软件测试网~+E(azX!?q\ }7A
      if x % n ==0 && v(n)==1
8u pU*v-t$}&Y0         return n51Testing软件测试网%W E7d(s| M
     end51Testing软件测试网 c0`0FQ6T&ad)_j
  end
} s[VZD/?0  151Testing软件测试网$U m3f)Y3~-v
end51Testing软件测试网z.O3JW4d` `/~
p v(600851475143) #6857
Hm2{${G0=end

TAG:

 

评分:0

我来说两句

Open Toolbar