import java.util.Scanner;
public class CheckPowerTwo {
public static void main(String args[])
{
Scanner ob= new Scanner(System.in);
int a,i;
System.out.println("Enter an integer");
a=ob.nextInt();
for( i=0;i<a;i++)
{
if(a==Math.pow(2,i))
{ System.out.println("The number is power of two");break;
}
}
if(i==a)
System.out.println("The number is not power of two");
}
}
No comments:
Post a Comment