A recursive definition of a n where a is an integer and n is a non-negative integer follows:
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:10| Question number:24.10
All Answers
total answers (1)
mypower.m
function res = mypower(a,n)
% recursively finds a^n
% Format of call: mypower(a,n)
% Returns a^n
if n == 0
res = 1;
else
res = a * mypower(a,n-1);
end
end
need an explanation for this answer? contact us directly to get an explanation for this answer