public static int numberofbits(int no) { int count; for (count = 0; no > 0; ++count) no &= no -1; return count; }