Probability of obtaining Prime Numbers as product of values obtained by throwing N dices | Function to find the value of power ( X , N ) ; Stores the value of ( X ^ N ) ; Calculate the value of power ( x , N ) ; If N is odd ; Update res ; Update x ; Update N ; Function to find the probability of obtaining a prime number as the product of N thrown dices ; Stores count of favorable outcomes ; Stores count of sample space ; Prthe required probability ; Driver code
def power ( x , N ) : NEW_LINE INDENT res = 1 NEW_LINE while ( N > 0 ) : NEW_LINE INDENT if ( N % 2 == 1 ) : NEW_LINE INDENT res = ( res * x ) NEW_LINE DEDENT x = ( x * x ) NEW_LINE N = N >> 1 NEW_LINE DEDENT return res NEW_LINE DEDENT def probablityPrimeprod ( N ) : NEW_LINE INDENT N_E = 3 * N NEW_LINE N_S = power ( 6 , N ) NEW_LINE print ( N_E , " ▁ / ▁ " , N_S ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT N = 2 NEW_LINE probablityPrimeprod ( N ) NEW_LINE DEDENT