MATLAB Answers

why my Matlab code is not passing the test suite? [Cody]

2 views (last 30 days)
Chandan Gupta
Chandan Gupta on 18 Jun 2020
Edited: Chandan Gupta on 18 Jun 2020
function a = ten2pow4(n)
format rat
c = zeros(1, n+1);
if n>0
c(2) = 2;
for i = 2:n
for r = 1:i-1
c(i+1) = c(i+1) + (((10^(i)/(i-1))-4^(r)*c(r+1))/(4^(i) + 1));
end
end
else
c(1) = 1;
end
c(1) = c(n+1);
a = flip(c);
end

  0 Comments

Sign in to comment.

Answers (0)