• + 2 comments
    #!/bin/python3
    
    import math
    import os
    import random
    import re
    import sys
    
    # Complete the extraLongFactorials function below.
    def extraLongFactorials(n):
        cache = {}
        def rec(n):
            if n in cache:
                return cache[n]
            if n == 1:
                return 1
            result = n * rec(n-1)
            cache[n] = result
            return result
        return rec(n)
    
    if __name__ == '__main__':
        n = int(input())
    
        print(extraLongFactorials(n))