Code Below:


//Mersenne number is a number whose binary form has no 0s(only 1s).
//Eg: The no. 7 is a mersenne number as its binary form is 111.
import java.util.*;
class mersenne_dtb
{
    public static void main()
    {
        Scanner s=new Scanner(System.in);
        int n,a,sum=0,k=0,c=0;
        System.out.println("enter a no.");
        n=s.nextInt();
        while (n>0)
        {
            a=n%2;
            if (a==0)
            c++;
            sum=sum+a*(int)Math.pow(10,k++); // binary no.
            n=n/2;
        }
        System.out.println(sum);
        if (c>0)
        System.out.println("not mersenne");
        else
        System.out.println("mersenne");
    }
}