#include <iostream>
usingnamespace std;
unsigned martian( unsigned a, unsigned b )
{
if ( b == 1 ) return a;
return ( b % 2 ? a : 0 ) + martian( a + a, b / 2 );
}
int main()
{
unsigned a, b;
cout << "Enter two numbers: "; cin >> a >> b;
cout << martian( a, b ) << '\n';
}
#include <iostream>
unsigned martian(unsigned a, unsigned b)
{
unsigned res {};
for (; b >= 1; b >>= 1, a <<= 1)
if (b % 2)
res += a;
return res;
}
int main() {
unsigned a{}, b{};
std::cout << "Enter two numbers: ";
std::cin >> a >> b;
std::cout << martian(a, b) << '\n';
}