Nth XOR Fibonacci number | Java implementation of the above approach ; Function to return the nth XOR Fibonacci number ; Driver code
class GFG { static 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 ) ; } public static void main ( String [ ] args ) { int a = 1 , b = 2 , n = 10 ; System . out . println ( nthXorFib ( n , a , b ) ) ; } }