Skip to content

Latest commit

 

History

History
28 lines (22 loc) · 839 Bytes

File metadata and controls

28 lines (22 loc) · 839 Bytes

#

Power Of Numbers Practice


#Given a number and its reverse. Find that number raised to the power of its own reverse.
#Note: As answers can be very large, print the result modulo 109 + 7.

long long check(int n,int r)
    {
        //int mod=1e9+7;
        if(r==0)
            return 1;
        if(n==0)
            return 0;
            
        if(r%2==0)
            {
                long long ans=check(n,r/2);
                return (ans%mod *ans%mod)%mod;
            }
        else
        {
             long long ans=check(n,(r-1)/2);
             return(ans%mod *ans%mod *n%mod)%mod;
        }
          
    }