Ways to express a number as product of two different factors | To count number of ways in which number expressed as product of two different numbers ; To store count of such pairs ; Counting number of pairs upto sqrt ( n ) - 1 ; To return count of pairs ; Driver Code
function countWays ( n ) { let count = 0 ; for ( let i = 1 ; i * i < n ; i ++ ) if ( n % i == 0 ) count ++ ; return count ; } let n = 12 ; document . write ( countWays ( n ) ) ;