Check out example codes for "pasar a binario recursivo". It will help you in understanding the concepts better.

Code Example 1

//imprime por pantalla el equivalente binario de n
int pasarBinario(int n){
  int bin;

  if(n < 2){ //significa que el numero es 0 o 1
    bin = n;
  }else{
    bin = (n % 2) + (10 * pasarBinario(n/2));
  }

  printf("bin: %d\n", bin);
  return bin;
}

Learn ReactJs, React Native from akashmittal.com