#include <stdio.h>

int N=19,P,Q=2;

int main() {
    scanf("%d", &N);
    scanf("%d", &Q);
    if(N==0) {
        printf("0");
    }
    while(N>0) {
        P=0;
        while(N>=Q) {
            N=N-Q;
            P=P+1;
        }
    printf("%d", N);
    N=P; //il risultato diventa il dividendo della porssima divisione intera
    }
}

Embed on website

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