不要追求绝对的公平,红尘之中没有公平而言,人活一世,难得糊涂。
it is no use doing what you like, you have got to like what you do.
Problem 1
上一篇 /
下一篇 2009-09-08 10:18:55
/ 个人分类:projecteuler题目 ruby实现
# Problem 1
$m$Q3Df.f5b4n0#If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
?o
P
PO\5fj+b0#Find the sum of all the multiples of 3 or 5 below 1000.
{9r9C]S-x051Testing软件测试网3I}7D9INA4U/k=begin
v;^ly P.tzC0def n(a,b)
51Testing软件测试网0S~8?E0Ssum =0
51Testing软件测试网"l ^ he L `+d3Gpc^b.upto(a){|n| sum+=n if n % 3 ==0 or n%5 ==0}
51Testing软件测试网S:U]M7~
Y&d-Zreturn sum
51Testing软件测试网CfeW,l'v.U'wend
-GK#F)p.PB0p n(999,1)
51Testing软件测试网a%c,|i)tyg$i4pR=end
收藏
举报
TAG: