Help me in solving LCPPCL115D problem

My issue

i am getting difficult for understanding theme of powers of 2

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
   int i=2,a=2;
    while(i<=128){
        i=i^a;
        cout<<i<<endl;
        i++;
    }
    
    
}

Learning course: ATT - C++
Problem Link: Print powers of 2 Practice Problem in ATT - C++ - CodeChef