There is no 0 index so I suspect you should just sum the entire array. Here's a hint - use the sum() function:
theSumX = sum(X);
theSumXY = sum(X .* Y);
If you really need to use a loop instead of sum(), then do something like this
theSum = 0;
for k = 1 : length(x)
theSum = theSum + x(k);
end
I hope that didn't give too much away. Actually it's just basic programming like you learned in your first programming class. You've probably seen it before and just forgot. Finding the sum, or the max or min, via a for loop is about as basic/trivial as you can get.