public int getSum(int binaryIndexedTree[], int index){
        index = index + 1;
        int sum = 0;
        while(index > 0){
            sum += binaryIndexedTree[index];
            index = getParent(index);
        }
        return sum;
    }
Start from index+1 if you want prefix sum 0 to index. Keep adding value
till you reach 0
src/com/interview/tree/FenwickTree.java