public class Solution

{

static int result = 0;

```
public void testing(int k, int index)
{
if (k == 0)
k = 1;
else
k = 0;
result += k * Convert.ToInt32(Math.Pow(2, index));
}
public int FindComplement(int num)
{
int n, index=0;
result = 0;
while(num!=0)
{
n = num % 2;
num = num / 2;
testing(n,index);
index++;
}
return result;
}
```

}