sum += x * i i += 1 } return sum end puts func([ 10,20,30,40,50 ]) ❖ ruby def func(ary): sum = 0 for i, v in enumerate(ary): sum += i * v return sum print func([10,20,30,40,50]) ❖ python ഁյతೖͷੈք
xs = minform 0 (length xs, xs) minform :: Int -> (Int, [Int]) -> Int minform a (n,xs) | n == 0 = a | m == b - a = minform b (n-m, vs) | otherwise = minform a (m, us) where (us,vs) = partition (< b) xs b = a + 1 + n `div` 2 m = length us