Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static int AmountOf1InBinaryRepresentation(int integer)
- {
- if(integer < 0 )
- throw new ArgumentException("Incoming value must be more or equal than 0");
- int count = 0;
- while (integer != 0)
- {
- count += integer % 2;
- integer = integer / 2;
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement