human
Find remainder when a number A raised to N factorial is divided by P | Function to calculate factorial of a Number.
Calculating factorial.
Returning factorial.
Function to calculate resultant remainder.
Function call to calculate factorial of n.
Calculating remainder.
Returning resultant remainder.
Driver Code.
Given Input.
Function Call"
Solution in Python:
assistant
#Here is code to find remainder when a number A raised to N factorial is divided by P and the other steps required.
 def fact ( n ) :
	ans = 1
	for i in range ( 2 , n + 1 , 1 ) :
		ans *= i
	return ans
def remainder ( n , a , p ) :
	len1 = fact ( n )
	ans = 1
	for i in range ( 1 , len1 + 1 , 1 ) :
		ans = ( ans * a ) % p
	return ans
if __name__ == ' _ _ main _ _ ' :
	A = 2
	N = 1
	P = 2
	print ( remainder ( N , A , P ) )