Nth term of a Leibniz Series
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (2)
Onimisi
il 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
Categorie
Scopri di più su Testing Frameworks in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!