//  Data Structures with Java by John R. Hubbard
//  Copyright McGraw-Hill, 2001
//  Problem 4.10 on page 85
//  Recursive Function that converts decimal to binary

public class Pr0410
{ public static void main(String[] args)
  { int n ;
    for ( int count = 0 ; count < 10 ; count++ )
    {  n =  (int)(Math.round(Math.random()*100));
       System.out.println("binary("+n+") = " + binary(n) );
    }  
  }
  public static String binary(int n)
  {  String s = "" + n%2;
     if (n < 2) return s ;               // basis
     return  binary(n/2) + s;  // recursion
  }
}
