int setBit(int n) { // Write Youwhile(r Code here int count=0; while((n%2)!=0) { n=n>>1; count++; } n=n+1; for(int i=0;i<count;++i) { n=n*2+1; } return n; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter