recurSum - the sum of that vector using recursion...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 %========================================================================== % Problem 1. Finding the sum of a vector with recursion %-------------------------------------------------------------------------- % % Problem Statement: % % Write a function called recurSum which takes in a vector and returns
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % the sum of that vector using recursion. % % Notes: % -You *must* use recursion to solve this problem. % function ans = recurSum(vec) if length(vec) == 0 ans = 0 else ans = vec(1) + recurSum(vec(2:end)) end...
View Full Document

This note was uploaded on 07/06/2009 for the course CS 1371 taught by Professor Stallworth during the Fall '08 term at Georgia Tech.

Ask a homework question - tutors are online