Nth term of a Leibniz Series
Ältere Kommentare anzeigen
I'm trying to create a function that will take a signle input (N) and output the Nth term in the Leibniz Series but for some reason my code keeps failing to pass these test: First term check, Check random variable.
Here is my function and how i am calling it.
test = LeibnizTerm(7)
function y = LeibnizTerm(N)
y = (-1)^N/(2*N+1);
end
Akzeptierte Antwort
Weitere Antworten (2)
Onimisi
am 22 Feb. 2023
n=0:19
x=(1)*1./((2*n)+1)
y=x.*(-1).^n
LeibnizTerms=y
n=0:19
x=(1)*1./((2*n)+1)
y=x.*(-1).^n
LeibnizTerms=y
Kategorien
Mehr zu Testing Frameworks finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!