//  Data Structures with Java by John R. Hubbard
//  Copyright McGraw-Hill, 2001
//  Problem 4.08 on page 85
//  Recursive Function that returns integer binary logarithm of n

public class Pr0408
{ public static void main(String[] args)
  { int n ;
    for ( int count = 0 ; count < 10 ; count++ )
    {  n =  (int)(Math.round(Math.random()*1000));
       System.out.println("lg("+n+") = " + lg(n) );
    }  
  }
  public static int lg(int n)
  { if (n==1) return 0 ;    // basis
    return  1 + lg(n/2) ;         // recursion
  }
}
