红宝石挖掘工

Dig ruby with Pickaxe

ProjectEuler_Problem5

xavier posted @ 2010年11月24日 06:30 in ProjectEuler with tags projecteuler ruby , 2064 阅读

What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

这不就是求1到20的最小公倍数么。。。

最小公倍数懒得写了直接用mathn的(mathn好强大,什么都有)

 

(1..20).inject(1) { |result, n| result.lcm n }

 


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter