We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
publicclassSolution{publicstaticvoidmain(String[]args){/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */Scannersc=newScanner(System.in);intnum=sc.nextInt();Inneri=newInner();Inner.Privateip=i.newPrivate();Stringassume=ip.powerof2(num)?"is":"is not a";System.out.printf("%d %s power of 2\n",num,assume);System.out.println("An instance of class: Solution.Inner.Private has been created");}}classInner{classPrivate{booleanpowerof2(intnum){while(num>1){if(num%2!=0)returnfalse;//n = 2k+1num/=2;}returntrue;}}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Can You Access?
You are viewing a single comment's thread. Return to all comments →
My solution: