Count of triplets till N whose product is at most N | Function to find number of triplets ( A , B , C ) having A * B * C <= N ; Stores the count of triplets ; Iterate a loop fixing the value of A ; Iterate a loop fixing the value of A ; Find the total count of triplets and add it to cnt ; Return the total triplets formed ; Driver Code
function countTriplets ( N ) { let cnt = 0 ; for ( let A = 1 ; A <= N ; ++ A ) { for ( let B = 1 ; B <= N / A ; ++ B ) { cnt += N / ( A * B ) ; } } return cnt ; } let N = 2 ; document . write ( countTriplets ( N ) ) ;