According To Data Science Topic 16 Sequence sum Task

 # sequence sum

# 1/1! + 2/2! + 3/3! + ... + n/n!

n = int(input('enter n'))

result = 0

fact = 1

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

  fact = fact * i

  result = result + i/fact

  print(result)

Result: enter n1

1.0

enter n2

1.0

2.0

enter n3

1.0

2.0

2.5


enter n4

1.0

2.0

2.5

2.6666666666666665

enter n5

1.0

2.0

2.5

2.6666666666666665

2.708333333333333



















  

Comments

Popular posts from this blog

According to Data Science Topic-13 Modules

Functions in Python:

According to Data Science Topic-12 If else program examples