Nth term of a Leibniz Series
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (2)
Onimisi
el 22 de Feb. de 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
Categorías
Más información sobre Testing Frameworks en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!