Search code examples
pythonsyntaxintegerpython-2.x

calculating factorial in Python


When calculating

math.factorial(100)

I get:

93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000L

Why is there an L at the end of the number?


Solution

  • L means it's a long as opposed to an int. The reason you see it is that you are looking at the repr of the long

    You can use

    print math.factorial(100)
    

    or

    str(math.factorial(100))
    

    if you just want the number