// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>

#include <stdlib.h>

using namespace std;

char c[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};

void calc(int n,int b)
{
  int a[33];
  int q = n;
  int k = 0;
  while(q!=0) {
      a[k]=q%b;
      q=q/b;
      k++;
  }
  cout << n << " = ";
  for(int i=k-1;i>=0;i--) {
      cout << c[a[i]];
  }
  cout << " base " << b << " (" << k << " digits)" << endl;
  return;
}
int main(int argc, char *argv[])
{
  for(int i=2;i<=16;i++) calc(11,i);
  calc(9, 10);
  calc(10, 10);
  calc(11, 10);
  calc(99, 10);
  calc(100, 10);
  calc(101, 10);
  calc(999, 10);
  calc(1000, 10);
  calc(1001, 10);
  return 0;
}
