text: Program to compute log a to any base b ( logb a ) | C program to find log ( a ) on any base b using Recursion ; Recursive function to compute log a to the base b ; Driver code
code: #include <stdio.h> NEW_LINE int log_a_to_base_b ( int a , int b ) { return ( a > b - 1 ) ? 1 + log_a_to_base_b ( a / b , b ) : 0 ; } int main ( ) { int a = 3 ; int b = 2 ; printf ( " % d STRNEWLINE " , log_a_to_base_b ( a , b ) ) ; a = 256 ; b = 4 ; printf ( " % d STRNEWLINE " , log_a_to_base_b ( a , b ) ) ; return 0 ; }