Count Pronic numbers from a given range | Function to check if x is a Pronic Number or not ; Check for Pronic Number by multiplying consecutive numbers ; Function to count pronic numbers in the range [ A , B ] ; Initialise count ; Iterate from A to B ; If i is pronic ; Increment count ; Print count ; Driver Code ; Function call to count pronic numbers in the range [ A , B ]
function checkPronic ( x ) { for ( let i = 0 ; i <= parseInt ( Math . sqrt ( x ) ) ; i ++ ) { if ( x == i * ( i + 1 ) ) { return true ; } } return false ; } function countPronic ( A , B ) { let count = 0 ; for ( let i = A ; i <= B ; i ++ ) { if ( checkPronic ( i ) ) { count ++ ; } } document . write ( count ) ; } let A = 3 , B = 20 ; countPronic ( A , B ) ;