How can I make this function into a recursive function? I was able to do it iteratively this way:
#include <iostream>
using namespace std;
int main (){
int n,pot,bin;
cout << endl << " Digite o Numero: ";
cin >> n;
pot = 1;
bin = 0;
while (n > 0){
bin += (n % 2)* pot;
pot *= 10;
n = n/2;
}
cout << " " << "Result: " << bin;
cin.get();
return 0;
}