Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: where is the mistake
Date: Sat, 26 Feb 2011 21:16:07 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 21
Message-ID: <ikbqin$4gr$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1298754967 4635 172.30.248.35 (26 Feb 2011 21:16:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 26 Feb 2011 21:16:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2758092
Xref: news.mathworks.com comp.soft-sys.matlab:712599

function y=intxexp(n)
% y=intxexp(n)
% n is positive integer
% y calculates p(n) the integrals of (x^n)*exp(x) for x is [0,1].
intxex=1;
y=1
for i=2:n
    i*intxex
    intxex=exp(1)-i*intxex;
    y=intxex
end

>>intxexp(17)
0.1043 correct!

>>intxexp(18)
0.8417 wrong!

>>intxexp(19)
-13.2742 wrong!
Thank you!