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 ; Input ; Function calling
function factorialWithoutMul ( N ) { let ans = N ; for ( let i = N - 1 ; i > 0 ; i -- ) { let sum = 0 ; for ( let j = 0 ; j < i ; j ++ ) sum += ans ; ans = sum ; } return ans ; } let N = 5 ; document . write ( factorialWithoutMul ( N ) ) ;