Write a MAIN function and a FUNCTION to compute the sum of the below series.


((-1)^(n+1)*n!)/(n*n) (from n=1 to infinity)

Within the MAIN function:
. Read a variable EPSILON of type DOUBLE (desired accuracy) from
the standard input.
EPSILON is an extremely small positive number which can be anything
between 1E-06 (10^(-6)) and 1E-12 (10^(-12)).
. EPSILON value will be passed to the FUNCTION as an argument.
Within the FUNCTION:
. In a do-while loop:
. Continue adding up the terms until |Sn+1 - Sn| < EPSILON.
. Sn is the sum of the first n-terms.
. Sn+1 is the sum of the first (n+1)-terms.
When the desired accuracy EPSILON is reached print the SUM and the number
of TERMS added to the sum.

You may want to check the question.

If I interpret your question correctly, you are to calculate:


Σ [(-1)^(i+1)]i!/i^2
i=1
is divergent.

You can show divergence by seeing each term (without regard to sign) as
T(i-1)=(i-1)!/(i-1)^2
So
T(i)=i!/i^2
=[T(i-1)*i]*(i-1)^2/i^2
=T(i-1) *(i-1)^2/i
which is clearly divergent.

excuse me if a run this in a c program. is it will be right or no?

It will never converge, because the terms are getting bigger and bigger.

For the sum of a series to converge, the limit of the nth term must be zero, when n->∞.

The limit of n!/n^2 is ∞, so the series will never converge.

Take the example of the first few terms:

n=1, T(1)=1!/1^2=1
n=2, T(2)=-2!/2^2=1/2
n=3, T(3)=3!/3^2=2/3
n=4, T(4)=-4!/4^2=3/2
n=5, T(5)=5!/5^2=24/5
n=6, T(6)=-6!/6^2=20
....
You can continue with the computer and the calculator.

I suspect there is a typo. One possibility is that the expression is meant to be:
((-1)^(n+1)*n!)/(n^n) (from n=1 to infinity)

Also ý don't understand the question. this question was publishted in system this is my homework of c++. and question was exactly same which ý wrote up. ý don't know how ý should to download in system the homework in c program or normaly in text. what you think how ý should to do this. ý think question is just to compute the forward series. do you have any idea??

Please confirm if the denominator was n^n or n*n, it makes the whole difference.

I do not think you should start working on C++ until you get the question cleared up. C++ is just a tool to get the answer, if there is one.

By the way, here are the first 40 sums according to your question. Hope it is obvious that it is not going to converge.

1 1.000000
2 0.500000
3 1.166667
4 -0.333333
5 4.466667
6 -15.533333
7 87.323810
8 -542.676190
9 3937.323810
10 -32350.676190
11 297540.232900
12 -3028859.767100
13 33817417.155977
14 -410969782.844023
15 5400916297.155977
16 -76328731702.844020
17 1154423614650.097200
18 -18605989057349.902000
19 318361048086229.060000
20 -5763893972355371.000000
21 110088582607484624.000000
22 -2212226970652035330.000000
23 46657369889243955000.000000
24 -1030509994230963400000.000000
25 23787426075098613000000.000000
26 -572797575591477840000000.000000
27 14363923206875396000000000.000000
28 -374524271450922870000000000.000000
29 10138866922056450000000000000.000000
30 -284586532869266930000000000000.000000
31 8271957332040122000000000000000.000000
32 -248691750611019940000000000000000.000000
33 7724969974652419000000000000000000.000000
34 -247666724696285400000000000000000000.000000
35 8187556105006690000000000000000000000.000000
36 -278844331850163950000000000000000000000.000000
37 9775029365174193000000000000000000000000.000000
38 -352428999351308500000000000000000000000000.000000
39 13058407345946156000000000000000000000000000.000000
40 -496888644683989900000000000000000000000000000.000000

ý took this from web site copy paste.. ý am sure is like this

I suggest you talk to the teacher or the author of the website and explain that the series diverges.

If it is a public site, I'd like to know the link.

On the other hand, I don't know if you got the right web site, I believe your question probably started with:

"Write a MAIN function and a FUNCTION to compute the sum of the below series.
1 + 2!/4 + 3!/27 + 4!/256 + ...
Determine the general term of the series first.
......
......"

from which the general term is
n!/(n^n) (and not n!/n^2)

except that your series is an alternating series.

QUESTÝON ÝS EXACTLY THÝS :

Write a MAIN function and a FUNCTION to compute the sum of the below series.

((-1)^(n+1)*n!)/(n*n) (from n=1 to infinity)

Within the MAIN function:
. Read a variable EPSILON of type DOUBLE (desired accuracy) from
the standard input.
EPSILON is an extremely small positive number which can be anything
between 1E-06 (10^(-6)) and 1E-12 (10^(-12)).
. EPSILON value will be passed to the FUNCTION as an argument.
Within the FUNCTION:
. In a do-while loop:
. Continue adding up the terms until |Sn+1 - Sn| < EPSILON.
. Sn is the sum of the first n-terms.
. Sn+1 is the sum of the first (n+1)-terms.
When the desired accuracy EPSILON is reached print the SUM and the number
of TERMS added to the sum.

TEST the program with different EPSILON values between 1E-06 and 1E-12.

There is a mistake in the question because the series will NOT converge, and will become an infinite loop (never stops).

The results are as shown above.
If you want to continue coding while waiting for your teacher's instructions (it's only one character to correct), you can proceed, but beware that it will run indefinitely if coded correctly.

Have you started coding? I do not think you need a pseudocode, since the instructions are explicit.