# -*- coding: UTF-8 -*-
# 作者：huanhuilong
# 标题：Python 函数递归
# 描述：递归计算阶乘函数

import math
import sys


def fact1(n):
    if n == 1:
        return 1
    return n*fact1(n-1)


def inner_fact_2(n, r):
    if n == 1:
        return r
    return inner_fact_2(n-1, r*n)


def fact2(n):
    return inner_fact_2(n, 1)


def inner_fact3(n, m):
    if m == n:
        return n
    return m*inner_fact3(n, m+1)


def fact3(n):
    return inner_fact3(n, 1)


def inner_fact_4(n, m, r):
    if m == n:
        return r*n
    return inner_fact_4(n, m+1, r*m)


def fact4(n):
    return inner_fact_4(n, 1, 1)


if __name__ == '__main__':
    print(fact1(100))
    print(fact2(100))
    print(fact3(100))
    print(fact4(100))
