Nth XOR Fibonacci number | C ++ implementation of the approach ; Function to return the nth XOR Fibonacci number ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int nthXorFib ( int n , int a , int b ) { if ( n == 0 ) return a ; if ( n == 1 ) return b ; if ( n == 2 ) return ( a ^ b ) ; return nthXorFib ( n % 3 , a , b ) ; } int main ( ) { int a = 1 , b = 2 , n = 10 ; cout << nthXorFib ( n , a , b ) ; return 0 ; }