# QM25P5A Editorial

Setter/Tester/Editorialist: Chandan Boruah

EASY

# PREREQUISITES:

Maths, Brute Force.

# PROBLEM:

Given a number in decimal form, convert it to binary, reverse it and then print the decimal form of the new reversed binary number.

# SOLUTION EXPLANATION:

Extract each number from the decimal by the number and modulo with 2. With every modulo divide the number by 2. The simple decimal to binary algorithm (https://www.rapidtables.com/convert/number/decimal-to-binary.html please scroll down in that link).
After that recreate the decimal number but(since reverse is asked) using that digits that was got from the end. Example: 1101, the decimal number can be found by 1 * 10^0+1 * 10^2+1 * 10^3. Please check the formula to convert binary to decimal (https://www.rapidtables.com/convert/number/binary-to-decimal.html please scroll down in that link). This can be done using a for loop and a math.power function.

# SOLUTIONS:

Setter's Solution
``````using System;
class some
{
public static void Main()
{
int nn=0;
while(n>0)
{
nn=nn*10+n%2;
n/=2;
}
char[]tt=(nn+"").ToCharArray();
nn=0;
for(int i=0;i<tt.Length;i++)
{
nn+=(int)Math.Pow(2,i)*(int.Parse(tt[i]+""));
}
Console.WriteLine(nn);
}
}
``````