Program to compute log a to any base b ( logb a ) | Recursive function to compute log a to the base b ; Driver code
function log_a_to_base_b ( a , b ) { var rslt = ( a > b - 1 ) ? 1 + log_a_to_base_b ( parseInt ( a / b ) , b ) : 0 ; return rslt ; } var a = 3 ; var b = 2 ; document . write ( log_a_to_base_b ( a , b ) + " " ) ; a = 256 ; b = 4 ; document . write ( log_a_to_base_b ( a , b ) ) ;