Greetings everyone, I am trying to create a function (without using loops) called LeibnizT that generates a row vector with the first n terms of the Leibniz series, the input argument is just n. My code is attached, thanks! function y=LeibnizT(n) y=(-1).^n/(2.*n+1) end
Prashant Kumar answered .
2025-11-20
Think about it. How does that generate a VECTOR? In what you wrote, is n a SCALAR? (Yes)
y=(-1).^n/(2.*n+1)