It is necessary with the help of Matlab to approximate the series:
y(n)=(1/0!) + (1/1!)+..+(1/n!) And you need to find n for which y will be equal to exp (1). I wrote the following code to solve this problem:
for n=1:100 while y>exp(1) y=(1/(factorial(n-1))) y=y+(1/(factorial(n))) disp(n) end end But n not reflected and after trying the variants of this code it is impossible to find n . Tell me how to solve the problem?
while y>exp(1)I think you wrote something wrong with that. The partial sum of a row is always under the limit. Andy= ... y=y+you surely did not make a mistake? I think the assignment here is too much. I have never written a matlab but I would have madewhile ( exp(1) - y > 1e-10) y = y + (1/(factorial(n)). By the way, the answer is when - never! - pavel