#include <stdio.h>
void to_base_n(int i, int j)
{
int r = 0;
if (i >= j)
to_base_n(i / j, j);
r = i % j;
printf("%d", r);
return;
}
int main()
{
int a, b;
printf("Please enter numbers and the base(q to quit):");
while (scanf_s("%d %d", &a, &b) == 2)
{
printf("%d based on %d is ", a, b);
to_base_n(a, b);
printf("\n");
}
return 0;
}