Mathematics/fast-exponentiation.cpp
// NOTE : Correct Answer Only Possible till 2^64 - 1 
NOTE : Correct Answer Only Possible till 2^64 - 1
NOTE : Correct Answer Only Possible till 2^64 - 1
ull exp_recursive(ull a,ull n) {
	if(n==0)	return 1;
	else if(n==1)	return a;
	else if(n%2==0){
		ull temp=exp_recursive(a,n/2);
		return temp*temp;
	}
	else{	
		ull temp=exp_recursive(a,(n-1)/2);
		return temp*temp*a;
	}
}
ull exp_recursive ( ull a , ull n ) { if ( n == 0 ) return 1 ; else if ( n == 1 ) return a ; else if ( n % 2 == 0 ) { ull temp = exp_recursive ( a , n / 2 ) ; return temp * temp ; } else { ull temp = exp_recursive ( a , ( n - 1 ) / 2 ) ; return temp * temp * a ; } }
NOTE : Correct Answer Only Possible till 2^64 - 1
NOTE : Correct Answer Only Possible till 2^64 - 1
// for n ODD