+ 1

In mathematics,the factorial of an integer n,denoted by n! is the following product:n!=1*2*...*n

For the given integer n calculate the value 1!+2!+3!+...+n! Try to discover the solution that uses only one for-loop.And don't use math module in this exercise. Ex input: 4 Ex output: 33 I can't do this!Could someone help me?

7th Feb 2019, 10:58 AM
周志桓
周志桓 - avatar
5 Answers
+ 4
周志桓 Sorry friend, this is not Python solution, but you can use the algorithm! // A simple for-loop calculation int n = 10; int result = 1; for (int i = 1; i <= n; ++i) { result *= i; } print( result ); //Output: 3628800 • We simply loop from 1 to n, adding the respectful number to the product at each iteration.
7th Feb 2019, 11:39 AM
Danijel Ivanović
Danijel Ivanović - avatar
+ 1
Thanks Jay Matthews and Danijel lvanovic
8th Feb 2019, 3:07 AM
周志桓
周志桓 - avatar
0
You can use recursion
7th Feb 2019, 11:21 AM
Akash
Akash - avatar
0
I use :for i in range... But I don't know how to do it.
7th Feb 2019, 11:26 AM
周志桓
周志桓 - avatar
0
But it starts is: a=int(input()) Ex input 5: 1!*2!*3!*4!*5!=153 Output is: 153
7th Feb 2019, 11:33 AM
周志桓
周志桓 - avatar