1486.cpp (202B)
1 class Solution { 2 public: 3 int xorOperation(int n, int start) { 4 int res = 0; 5 6 for (int i = 0; i < n; i++) { 7 res ^= start + 2 * i; 8 } 9 10 return res; 11 } 12 };