Computer Science, asked by sangeethar295, 16 days ago

1. Write a program to find the sum of the series S= 1+ 3/2! +5/3! +7/45+...n​

Answers

Answered by ay8076191
0

Explanation:

hlo mate here's your answer

if n is even, sum is -(n/2)

if n is odd, sum = n-(sum where n = n-2)

I’m assuming by …? you mean …n, and that you’re looking for a formula/algorithm for determining the sum for any value of n. But, as alluded to in previous answers, this will depend on whether n is preceded by a “-” or by a “+”.

If n is preceded by “-”:

1–2+3–4+5–6+7-…-n

(1–2)+(3–4)+(5–6)+(7–8)…((n-1)-n) = ?

If n = 1, the answer is 1.

If n = 2, then we have 1–2 = -1.

If n = 3, then we have -1+3 = 2

if n = 4, then we have 2–4 = -2

if n = 5, then we have -1 + -1 + 5 = -2 + 5 = 3

if n = 6, then we have 3 - 6 = -3

Let’s see if we can find a pattern in the above (other answers have already revealed the tendency of the summation depending on -n or +n, but I don’t think that that was your question).

Since I’ve specified that we’re currently looking at the case where the sequence ends in -n, let’s only look at those situations.

We know that (by looking at the sequence), the sequence will end in -n is n is an even number (look up there: -2…-4…-6…-n)

So, saying that this sequence ends in -n is that same thing as saying that n is even.

Now, let’s look at those first few even examples

n = 2, sum is -1

n = 4, sum is -2

n = 6, sum is -3

So, with each successive even number, the sum decreases by 1.

Also, notice that -1 = -(2/2), -2=-(4/2), -3=-(6/2)

In other words, the sum is equal to the negative of half of n

We could write this as: if n is even, sum is -(n/2).

Now, let’s check out our solution for sequences ending in +n.

1–2+3–4+5–6+7-…+n

(1–2)+(3–4)+(5–6)+(7–8)+…+n = ?

If n = 1, the answer is 1.

If n = 2, then we have 1–2 = -1.

If n = 3, then we have -1+3 = 2

if n = 4, then we have 2–4 = -2

if n = 5, then we have -1 + -1 + 5 = -2 + 5 = 3

if n = 6, then we have 3 - 6 = -3

Let’s see if we can find a patter with the sequences ending in +n, which are those cases where n is not even (aka n is odd).

n=1, sum is 1

n=3, sum is 2

n=5, sum is 3

Notice that with each successive odd n, the sum is increased by 1.

Also notice, that the sum is equal to n minus the previous sum.

n=5, sum is 3, which is 5–2, and 2 is the sum where n=3.

n=3, sum is 2, which is 3–1, and 1 is the sum where n = 1.

Let’s test this for n = 7

We know that for n=6, sum is -3. So let’s just add 7 to -3.

7+-3 = 4.

n=7, sum is 4, which is 7–3, and 3 is the sum where n = 5.

Alright, so how do we simplify this and make it more generally applicable?

We could write this as: if n is odd, sum = n-(sum where n = n-2)

Right?

sum = n-(sum where n = n-2)

Try 7: sum=7-(sum where n=5), sum=7-(3), sum=4.

Woohoo!

If you thought this one was neat (or maybe you thought I took shortcuts or cheated by using the sum function as part of my solution), check out recursion. It’s awesome.

NOTE: that whole sum=n-(sum where n=n-2) thing? You might be wondering where I got that n=n-2, right? That’s just short hand for “the next lowest odd number” for our purposes. So, if n=7, then n-2=5, and 5 is the next lowest odd value for n.

So, to find any specific sum for any value of n for that particular sequence you’ve specified…

if n is even, sum is -(n/2)

if n is odd, sum = n-(sum where n = n-2)

Group the numbers into pairs like so:

(1−2)+(3−4)+(5−6)+(7−8)+...

Then it is

(−1)+(−1)+(−1)+(−1)+...=−1−1−1−1−...

And that sum up to the negative infinity

While if we consider this series by adding and subtracting 1s:

1−1+1−1+1−1+1−1+1−1...

Then we have 2 answers according to the way we put the bracket

(1−1)+(1−1)+(1−1)+(1−1)+...=0+0+0+0+...=0

1+(−1+1)+(−1+1)+(−1+1)+...=1+0+0+0+...=1

But there is a third answer

Suppose that S=1−1+1−1+1−1+...

1−S=1−(1−1+1−1+1−1+...)=1−1+1−1+1−1+...=S

The we solve the following equation

S=1−S

S+S=1

2S=1

S=1/2

And this is the weirdest answer, since by adding and subtraction 1 we get 1/2, but this has been proved.

i hope its help you mark as brainlist plz

Answered by jaswasri2006
0

Explanation:

⇒⇒⇒⇒⇒ \:  \:  \: ⇒⇒⇒

Similar questions