Find the value of the function Y = ( X ^ 6 + X ^ 2 + 9894845 ) % 971 | C # implementation of above approach ; computing ( a ^ b ) % c ; Driver code
using System ; class GFG { static long modpow ( long base1 , long exp , long modulus ) { base1 %= modulus ; long result = 1 ; while ( exp > 0 ) { if ( ( exp & 1 ) > 0 ) result = ( result * base1 ) % modulus ; base1 = ( base1 * base1 ) % modulus ; exp >>= 1 ; } return result ; } public static void Main ( ) { long n = 654654 ; long mod = 971 ; Console . WriteLine ( ( ( modpow ( n , 6 , mod ) + modpow ( n , 2 , mod ) ) % mod + 355 ) % mod ) ; } }