Advertisement
d_brezoev

Untitled

Nov 7th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Numerics;
  7.  
  8. class InvertingBits
  9. {
  10.     static void Main(string[] args)
  11.     {
  12.         int n = 10;
  13.         int pow = (int)Math.Log(n, 2)+1;
  14.         //Console.WriteLine(pow);
  15.         int assist = (int)Math.Pow(2, pow) - 1;
  16.         int result = n ^ assist;
  17.         Console.WriteLine(result);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement