Find XOR of 1 to n
👉👉👉 https://www.dyclassroom.com/programming/find-xor-of-1-to-n
In this programming tutorial we will find XOR of 1 to n.
About XOR operator
XOR operator is a binary operator and it gives us 1 for odd number of 1s and 0 for even number of 1s.
In programming XOR is represented by
^
caret symbol.
We also represent XOR with this
⊕
plus inside circle symbol.
Following is the truth table for the XOR operator.
A | B | A^B |
---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
Remember!XOR of odd 1s = 1XOR of even 1s = 0
Check out Boolean Algebra tutorial.
Let's solve the problem.
#programming #coding #xor #computer #tutorial #dyclassroom