What I'm trying to figure out here is, if there is any way that I can find such a pair of integer such that one of it is the smallest of any number occurring in any pair of number which satisfies A XOR B = N
Asked
Active
Viewed 73 times
0
-
1... I';m not clear what you are asking. Can you give an example? – Bram28 Dec 22 '19 at 17:26
-
@Bram28 thanks for asking, for example, to have 6 as XOR I have a pair (7, 1) where B is the smallest possible natural number. So is there any way I can generalize for any number? – Mohil Khare Dec 22 '19 at 17:33
-
You can always pick B=1 and A=B XOR N. – Dec 22 '19 at 17:52
-
@MatthewDaly many thanks for this, just curious, what if I wish to ensure that neither A nor B can be greater than N? – Mohil Khare Dec 22 '19 at 18:06
-
Then the smallest possible value of B would correspond to the least possible 1 in the binary expansion of N. For instance if N=12=1100 in binary, then you'd need A=8, B=4 to avoid having an A greater than N. – Dec 22 '19 at 18:09