Code Festival C Div and Add by shinh (par)

$<.map{|l|def calc(v)
s=0
i=v
while i>0
s+=i%10
i/=10
end
a=[0]
2.upto(v){|i|if v%i==0
a << calc(v/i)
end}
s + a.max
end
p calc(l.to_i)}
__END__
XXXXXXXXXXXXXX

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page