recurMod - % This function should use recursion to produce...

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

View Full Document Right Arrow Icon
Sheet1 Page 1 %======================================================================== % Problem 4. Recursive Math %-------------------------------------------------------------------------- % % Problem Statement % % Write a function named recMod that takes in 2 numbers and % returns the remainder of the first number divided by the second number.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % This function should use recursion to produce the mod, and perform the % same way as MATLAB's built-in function. % % % Notes: % - you may *not* use the MATLAB built in function mod() % - you must use recursion % function rem = recurMod(x,y) z = 0 if (x/y) == 1 rem = 0 else while z < x rem = x - z z = z + y end end...
View Full Document

Ask a homework question - tutors are online