The Algorithms logo
The Algorithms
AboutDonate
function prefix_sum(arr::Vector{T})where T<:Number
    pre=[]
    preans=zero(T)
    for i in arr
        preans+=i
        push!(pre,preans)
    end
    return pre
end

Prefix Sum

R