<reponame>lukeaparker/CS-1.3-Core-Data-Structures
#!python


def factorial_iterative(n):
    if n < 0:
        return -1
    else:
        factorial = 1
        for i in range(1, n+1):
            factorial *= i
        return print(factorial) 
factorial_iterative(5)

def factorial_recursive(n):
    # check if n is one of the base cases
    if n == 0 or n == 1:
        return 1
    # check if n is an integer larger than the base cases
    elif n > 1:
        # call function recursively
        return n * factorial_recursive(n - 1)


def main():
    import sys
    args = sys.argv[1:]  # Ignore script file name
    if len(args) == 1:
        num = int(args[0])
        result = factorial(num)
        print('factorial({}) => {}'.format(num, result))
    else:
        print('Usage: {} number'.format(sys.argv[0]))


if __name__ == '__main__':
    main()

#!python


def factorial_iterative(n):
    if n < 0:
        return -1
    else:
        factorial = 1
        for i in range(1, n+1):
            factorial *= i
        return print(factorial) 
factorial_iterative(5)

def factorial_recursive(n):
    # check if n is one of the base cases
    if n == 0 or n == 1:
        return 1
    # check if n is an integer larger than the base cases
    elif n > 1:
        # call function recursively
        return n * factorial_recursive(n - 1)


def main():
    import sys
    args = sys.argv[1:]  # Ignore script file name
    if len(args) == 1:
        num = int(args[0])
        result = factorial(num)
        print('factorial({}) => {}'.format(num, result))
    else:
        print('Usage: {} number'.format(sys.argv[0]))


if __name__ == '__main__':
    main()
#!python # check if n is one of the base cases # check if n is an integer larger than the base cases # call function recursively # Ignore script file name