We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b715a62 commit 3a2fa6dCopy full SHA for 3a2fa6d
ex060.py
@@ -0,0 +1,18 @@
1
+# Write a program that reads any number and displays its factorial.
2
+# just in four lines
3
+'''from math import factorial
4
+number = int(input('Enter a number:'))
5
+result = factorial(number)
6
+print(f'The factorial of {number}! is {result}')'''
7
+
8
+# or you can make it prettier
9
10
+counter = number
11
+fat = 1
12
+print(f'Calculating {number}! =', end= ' ')
13
+while counter > 0:
14
+ print(f'{counter}', end= ' ' )
15
+ print(' x ' if counter > 1 else ' = ', end=' ')
16
+ fat *= counter
17
+ counter -= 1
18
+print(f'{fat}.')
0 commit comments