Probability that an arbitrary positive divisor of 10 ^ X is an integral multiple of 10 ^ Y | Function to calculate and print the required probability ; Count of potential divisors of X - th power of 10 which are also multiples of Y - th power of 10 ; Count of divisors of X - th power of 10 ; Calculate GCD ; Print the reduced fraction probability ; Driver Code
function prob ( x , y ) { var num = Math . abs ( x - y + 1 ) * Math . abs ( x - y + 1 ) ; var den = ( x + 1 ) * ( x + 1 ) ; var gcd = __gcd ( num , den ) ; document . write ( num / gcd + " " + den / gcd + " " ) ; } function __gcd ( a , b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } var X = 2 , Y = 1 ; prob ( X , Y ) ;