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.
why u used n=n-pow(2,floor(log (n)/log (2)));
if n is not a poweer of two then reduce it to nearest small power of 2 less than n ryt?
then why not n=pow(2,floor(log (n)/log (2)));
e.g
n=7;
pow(2,floor(7)/floor(2))=4;
now n shoud be 4 not 7-4 m i ryt?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Counter game
You are viewing a single comment's thread. Return to all comments →
why u used n=n-pow(2,floor(log (n)/log (2))); if n is not a poweer of two then reduce it to nearest small power of 2 less than n ryt? then why not n=pow(2,floor(log (n)/log (2))); e.g n=7; pow(2,floor(7)/floor(2))=4; now n shoud be 4 not 7-4 m i ryt?