Factorial of a number without using multiplication | Function to calculate factorial of the number without using multiplication operator ; Variable to store the final factorial ; Outer loop ; Inner loop ; Driver code ; Input ; Function calling
def factorialWithoutMul ( N ) : NEW_LINE INDENT ans = N NEW_LINE i = N - 1 NEW_LINE while ( i > 0 ) : NEW_LINE INDENT sum = 0 NEW_LINE for j in range ( i ) : NEW_LINE INDENT sum += ans NEW_LINE DEDENT ans = sum NEW_LINE i -= 1 NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 5 NEW_LINE print ( factorialWithoutMul ( N ) ) NEW_LINE DEDENT