+ 1
How to calculate factorial in Python 3.6.2?
I would like import 'math' but I can only import 'cmath'. And there isnot gamma function or factorial. I donot want to work with complex numbers, is there any way how to import 'math' instead of 'cmath'?
8 ответов
+ 10
In sololearn playground fortunately it is working:
import math
n = int(input("Type in the number: "));
f = math.factorial(n);
print (f);
+ 3
It should be possible to import math in python 3.6.2
I had extra a look in the docs. Here
https://docs.python.org/3.6/library/math.html
Which error occurs when you try to import math?
+ 3
okay. this is really strange. Sorry, but I have no idea why it doesn't work. :(
maybe you install a little older version, 3.5 or so.
+ 3
try this:
help ('modules')
and look if math is listed
+ 2
Thanks for your help.
+ 1
'No module named math' I can import only cmath :(
+ 1
n = int(input("!n="))
def factorial(n):
fact = 1
for i in range(n):
fact = fact*(i+1)
print (fact)
factorial(n)
0
It also work on PC, but it say that it is mistake, and write it red, but now it works. I do not know why...