UNB/ CS/ David Bremner/ teaching/ java/ NumToString.java
public class NumToString{

  static String numToString(long num, int base){

    String retVal="";

    long leftover=num;

    while(leftover > 0){
      
      long remainder=leftover % base;
      retVal = remainder+retVal;
      leftover=leftover/base;
    }
    return retVal;
  }

  public static void printConvert(long num, int base){
    System.out.println(num + " in base " + base +  " = " 
                       +numToString(num,base));
  }


  public static void main(String args[]){

    printConvert(185,2);
    printConvert(185,7);
    printConvert(123,10);
    printConvert(123,8);
    
  }
}