Java, very simple code and self-evident, explanation
for example:\n100110, its complement is 011001, the sum is 111111. So we only need get the min number large or equal to num, then do substraction\n\n    public 
for example:\n100110, its complement is 011001, the sum is 111111. So we only need get the min number large or equal to num, then do substraction\n```\n    public int findComplement(int num) \n    {\n        int i = 0;\n        int j = 0;\n        \n        while (i < num)\n        {\n            i += Math.pow(2, j);\n            j++;\n        }\n        \n        return i - num;\n    }\n```
[]