#include <stdio.h>

int N,P,Q; // dichiarazione variabile

int main()
{
  scanf("%d",&N); // INPUT N
  scanf("%d",&Q); // INPUT Q Base scelta per la trasformazione
  if( N == 0 ) {
      printf("0");
  }
  while( N > 0 ) 
  {
    // ------- DIVISIONE INTERA PER 2 ---------
    P = 0;
    while( N >= Q ) 
    {
      N = N - Q;
      P = P + 1;
    }
    printf("%d",N); // STAMPA RESTO (COEFF)
    // ----------------------------------------
    N = P;          // IL RISULTATO DIVENTA IL 
                    // DIVIDENDO DELLA PROSSIMA 
                    // DIVISIONE INTERA
  }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: