Program to find the value of P ( N + r ) for a polynomial of a degree N such that P ( i ) = 1 for 1 Ã ¢ â €°¤ i Ã ¢ â €°¤ N and P ( N + 1 ) = a | ''Function to calculate factorial of N ; '' Base Case ; '' Otherwise, recursively  calculate the factorial ; ''Function to find the value of P(n + r) for polynomial P(X) ; ''Stores the value of k ; '' Store the required answer ; '' Iterate in the range [1, N] and  multiply (n + r - i) with answer ; '' Add the constant value C as 1 ; '' Return the result ; ''Driver Code
def fact ( n ) : NEW_LINE INDENT if n == 1 or n == 0 : NEW_LINE return 1 NEW_LINE else : NEW_LINE return n * fact ( n - 1 ) NEW_LINE DEDENT def findValue ( n , r , a ) : NEW_LINE INDENT k = ( a - 1 ) // fact ( n ) NEW_LINE answer = k NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE answer = answer * ( n + r - i ) NEW_LINE DEDENT answer = answer + 1 NEW_LINE INDENT return answer NEW_LINE DEDENT N = 1 NEW_LINE A = 2 NEW_LINE R = 3 NEW_LINE print ( findValue ( N , R , A ) ) NEW_LINE