File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ * * *
2+ ** Question:**
3+ Write a program which can compute the factorial of a given numbers.
4+ The results should be printed in a comma-separated sequence on a single line.
5+ Suppose the following input is supplied to the program:
6+ 8
7+ Then, the output should be:
8+ 40320
9+
10+ ** Hints:**
11+ In case of input data being supplied to the question, it should be assumed to be a console input.
12+
13+ ** Solution:**
14+ <pre >
15+ def fact(x):
16+ if x == 0:
17+ return 1
18+ return x * fact(x - 1)
19+ </pre >
20+ ***
21+ ** Question:**
22+ Write a program which can compute the factorial of a given numbers.
23+ The results should be printed in a comma-separated sequence on a single line.
24+ Suppose the following input is supplied to the program:
25+ 8
26+ Then, the output should be:
27+ 40320
28+
29+ ** Hints:**
30+ In case of input data being supplied to the question, it should be assumed to be a console input.
31+
32+ ** Solution:**
33+ <pre >
34+ def fact(x):
35+ if x == 0:
36+ return 1
37+ return x * fact(x - 1)
38+ </pre >
You can’t perform that action at this time.
0 commit comments