Write a function that adds all the even numbers between 2 an
Write a function that adds all the even numbers between 2 and 3^n, where n is a number passed to the faunction.
Solution
function y=sumnalleven(n)
y=0;
for i=2:3^n
if rem(i,2)==0
y=y+i;
end
end
RESULT:
>> sumnalleven(2)
ans =
20
>> sumnalleven(5)
ans =
14762
