Math, asked by Anonymous, 19 days ago


 \textbf{ \textsf{ \large \underline{Python program}}}
Write a program in python to solve the following series.

 \boxed{ \displaystyle \dfrac{1}{1}   +  \frac{1 + 2}{1 \times 2}  +  \frac{1 + 2 + 3}{1 \times 2 \times 3}  + ... +  \frac{1 + 2 + 3 + ... + 10}{1 \times 2 \times 3 \times ... \times 10} }

Answers

Answered by anindyaadhikari13
10

SOLUTION:

The given problem is solved using language - Python.

limit = 10

numerator = 1

denominator = 1

sum = 0

for i in range(1,limit+1):

   sum += numerator/denominator

   numerator += (i + 1)

   denominator *= (i + 1)

print(f'The sum of first {limit} terms of the series is {sum}')

Explanation:

  1. Line 1: Initialise limit = 10 as we have to display the sum of first ten terms of the series.
  2. Line 2-3: Initialise numerator and denominator. These two variable will be used while calculating the sum.
  3. Line 4: Initialise sum = 0. 'sum' variable will calculate the sum of the series.
  4. Line 5: Loop is created.
  5. Line 6: Sum variable is updated.
  6. Line 7-8: Numerator and denominator value is updated to get the next term.
  7. Line 9: Finally, the sum is displayed!

For More..

☛ Recursive implementation of the problem.

Nth term of the series is given as:

\rm\longrightarrow a_{n}=\dfrac{f(n)}{n!}

Where:

\rm\longrightarrow f(n)=1+2+3+...+n=\dfrac{n(n+1)}{2}

The recursive algorithm is as follows:

\rm\longrightarrow sum(n)=\begin{cases}\rm a_{n}+sum(n-1), n>0\\ \rm0, n=0\end{cases}

The Co‎de:

from math import factorial as fact

f=lambda x:x*(x+1)//2

def calc(limit):

   if limit:  # base case

       return f(limit)/fact(limit) + calc(limit-1)

   return 0

sum=calc(10)

print(f'The sum of first 10 terms of the series is {sum}')

Base case is the condition that prevents the recursive function from calling itself forever.

Output:

The sum of first 10 terms of the series is 4.077420910493827


anindyaadhikari13: Thanks for the brainliest ^_^
Answered by r27272278
0

SOLUTION:

The given problem is solved using language - Python.

limit = 10

numerator = 1

denominator = 1

sum = 0

for i in range(1,limit+1):

sum += numerator/denominator

numerator += (i + 1)

denominator *= (i + 1)

print(f'The sum of first {limit} terms of the series is {sum}')

Explanation:

Line 1: Initialise limit = 10 as we have to display the sum of first ten terms of the series.

Line 2-3: Initialise numerator and denominator. These two variable will be used while calculating the sum.

Line 4: Initialise sum = 0. 'sum' variable will calculate the sum of the series.

Line 5: Loop is created.

Line 6: Sum variable is updated.

Line 7-8: Numerator and denominator value is updated to get the next term.

Line 9: Finally, the sum is displayed!

For More..

☛ Recursive implementation of the problem.

Nth term of the series is given as:

\rm\longrightarrow a_{n}=\dfrac{f(n)}{n!}⟶a

n

=

n!

f(n)

Where:

\rm\longrightarrow f(n)=1+2+3+...+n=\dfrac{n(n+1)}{2}⟶f(n)=1+2+3+...+n=

2

n(n+1)

The recursive algorithm is as follows:

\begin{gathered}\rm\longrightarrow sum(n)=\begin{cases}\rm a_{n}+sum(n-1), n > 0\\ \rm0, n=0\end{cases}\end{gathered}

⟶sum(n)={

a

n

+sum(n−1),n>0

0,n=0

The Co‎de:

from math import factorial as fact

f=lambda x:x*(x+1)//2

def calc(limit):

if limit: # base case

return f(limit)/fact(limit) + calc(limit-1)

return 0

sum=calc(10)

print(f'The sum of first 10 terms of the series is {sum}')

Base case is the condition that prevents the recursive function from calling itself forever.

Output:

The sum of first 10 terms of the series is 4.077420910493827

Similar questions