View difference between Paste ID: cdx8JJH1 and L7LaEnMB
SHOW: | | - or go back to the newest paste.
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;
15+
        int assist = (int)Math.Pow(2, pow) - 1;
16
        int result = n ^ assist;
17
        Console.WriteLine(result);
18
    }
19
}