Recurrence Relation

Recurrence Relation

Solution 

mydeterm.m 

function s = mydeterm(A)

n=length(A);

if n==1

s=A;

else s=0;

for j=1:n

C=A;

C(1,:)=[];

C(:,j)=[];

s=s+A(1,j)*(-1)^(j+1)*mydeterm(C);

end

end 

myfac.m 

function s = myfac(n)

if n==0

s=1;

else s=n*myfac(n-1);

end 

myfib.m 

function s = myfib(n)

if n==1

s=1;

elseif n==2

s=1;

else s=myfib(n-1)+myfib(n-2);

end

Solutions.m 

% Question 1.

myfib(25)

% Question 2.

myfac(80)

% Question 3.

A=magic(5);

mydeterm(A)

B=magic(6);

mydeterm(B)