栏目管理员
查看详细资料
TOP
def Euler12(x) factor = 0 num = 1 while factor <= x num += 1 tr = (1+num)*num/2 arr=[] n = 2 tt = tr kk = 1 while tt != 1 if tt % n == 0 then kk += 1 tt = tt / n else arr<<kk kk = 1 n += 1 end end arr<<kk factor = 1 arr.each {|h| factor *= h } end puts tr, "\n" end #test Euler12(500)
江湖新秀
#test def geti(i) p i i end i = 1 begin i += 1 end while geti(i) < 3 #=>2 #=>3 i = 1 i += 1 while geti(i) < 3 #=>1 #=>2 #=>3