Probability that an arbitrary positive divisor of 10 ^ X is an integral multiple of 10 ^ Y | Java program to find the probability of an arbitrary positive divisor of Xth power of 10 to be a multiple of Yth power of 10 ; 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
import java . util . * ; class GFG { static void prob ( int x , int y ) { int num = Math . abs ( x - y + 1 ) * Math . abs ( x - y + 1 ) ; int den = ( x + 1 ) * ( x + 1 ) ; int gcd = __gcd ( num , den ) ; System . out . print ( num / gcd + " / " + den / gcd + "NEW_LINE"); } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int X = 2 , Y = 1 ; prob ( X , Y ) ; } }