Given two numbers **X **and **Y**, the task is to find the probability that an arbitrary positive divisor of **10 ^{X}** is an integral multiple of

**10**.

^{Y}**Note: **Y should be <= X.

**Examples:**

Input:X = 2, Y = 1

Output:4/9

Explanation:

Positive divisors of 10^{2}are 1, 2, 4, 5, 10, 20, 25, 50, 100. A total of 9.

Multiples of 10^{1}upto 10^{2}are 10, 20, 50, 100. A total of 4.

P(divisor of 10^{2}is a multiple of 10^{1}) = 4/9.

Input:X = 99, Y = 88

Output:9/625

Explanation:

A = 10^{99}, B = 10^{88}

P(divisor of 10^{99}is a multiple of 10^{88}) = 9/625

**Pre-requisites:** Total number of divisors of a number

**Approach:**

In order to solve the problem, we need to observe the steps below:

- All divisors of 10
^{X}will be of the form:

(2

* 5^{P}), where 0 <= P, Q <= X^{Q} - Find the number of Prime factors of
**10**^{X}

10

^{X}= 2^{X}* 5^{X} - Hence total number of divisors of 10
^{X}will be:**( X + 1 ) * ( X + 1 )**. - Now, consider all multiples of 10
^{Y}which can be potential divisors of 10^{X}. They are also of the form:

( 2

^{A}* 5^{B}), where Y <= A, B <= X. - So, count of potential divisors of
**10**which are also multiples of^{X}**10**is^{Y}**( X – Y + 1 ) * ( X – Y + 1 )**. - Hence, required probability is
**(( X – Y + 1 ) * ( X – Y + 1 )) / (( X + 1 ) * ( X + 1 ))**. Computing the value of the expression for given values of**X**and**Y**gives us the required probability.

Below is the implementation of the above approach:

## C++

`// C++ program to find the probability ` `// of an arbitrary positive divisor of ` `// Xth power of 10 to be a multiple of ` `// Yth power of 10 ` ` ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` `#define int long long int ` ` ` `// Function to calculate and print ` `// the required probability ` `void` `prob(` `int` `x, ` `int` `y) ` `{ ` ` ` `// Count of potential divisors ` ` ` `// of X-th power of 10 which are ` ` ` `// also multiples of Y-th power ` ` ` `// of 10 ` ` ` `int` `num = ` `abs` `(x - y + 1) ` ` ` `* ` `abs` `(x - y + 1); ` ` ` ` ` `// Count of divisors of X-th ` ` ` `// power of 10 ` ` ` `int` `den = (x + 1) * (x + 1); ` ` ` ` ` `// Calculate GCD ` ` ` `int` `gcd = __gcd(num, den); ` ` ` ` ` `// Print the reduced ` ` ` `// fraction probability ` ` ` `cout << num / gcd << ` `"/"` ` ` `<< den / gcd << endl; ` `} ` ` ` `// Driver Code ` `signed` `main() ` `{ ` ` ` `int` `X = 2, Y = 1; ` ` ` `prob(X, Y); ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// 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 ` `import` `java.util.*; ` ` ` `class` `GFG{ ` ` ` `// Function to calculate and print ` `// the required probability ` `static` `void` `prob(` `int` `x, ` `int` `y) ` `{ ` ` ` ` ` `// Count of potential divisors ` ` ` `// of X-th power of 10 which are ` ` ` `// also multiples of Y-th power ` ` ` `// of 10 ` ` ` `int` `num = Math.abs(x - y + ` `1` `) * ` ` ` `Math.abs(x - y + ` `1` `); ` ` ` ` ` `// Count of divisors of X-th ` ` ` `// power of 10 ` ` ` `int` `den = (x + ` `1` `) * (x + ` `1` `); ` ` ` ` ` `// Calculate GCD ` ` ` `int` `gcd = __gcd(num, den); ` ` ` ` ` `// Print the reduced ` ` ` `// fraction probability ` ` ` `System.out.print(num / gcd + ` `"/"` `+ ` ` ` `den / gcd + ` `"\n"` `); ` `} ` ` ` `static` `int` `__gcd(` `int` `a, ` `int` `b) ` `{ ` ` ` `return` `b == ` `0` `? a : __gcd(b, a % b); ` `} ` ` ` `// Driver code ` `public` `static` `void` `main(String[] args) ` `{ ` ` ` `int` `X = ` `2` `, Y = ` `1` `; ` ` ` ` ` `prob(X, Y); ` `} ` `} ` ` ` `// This code is contributed by amal kumar choubey ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 program to find the probability ` `# of an arbitrary positive divisor of ` `# Xth power of 10 to be a multiple of ` `# Yth power of 10 ` `from` `math ` `import` `*` ` ` `# Function to calculate and print ` `# the required probability ` `def` `prob(x, y): ` ` ` ` ` `# Count of potential divisors ` ` ` `# of X-th power of 10 which are ` ` ` `# also multiples of Y-th power ` ` ` `# of 10 ` ` ` `num ` `=` `abs` `(x ` `-` `y ` `+` `1` `) ` `*` `abs` `(x ` `-` `y ` `+` `1` `) ` ` ` ` ` `# Count of divisors of X-th ` ` ` `# power of 10 ` ` ` `den ` `=` `(x ` `+` `1` `) ` `*` `(x ` `+` `1` `) ` ` ` ` ` `# Calculate GCD ` ` ` `gcd1 ` `=` `gcd(num, den) ` ` ` ` ` `# Print the reduced ` ` ` `# fraction probability ` ` ` `print` `(num ` `/` `/` `gcd1, end ` `=` `"") ` ` ` `print` `(` `"/"` `, end ` `=` `"") ` ` ` `print` `(den ` `/` `/` `gcd1) ` ` ` `# Driver Code ` `if` `__name__ ` `=` `=` `'__main__'` `: ` ` ` ` ` `X ` `=` `2` ` ` `Y ` `=` `1` ` ` ` ` `prob(X, Y) ` ` ` `# This code is contributed by Surendra_Gangwar ` |

*chevron_right*

*filter_none*

## C#

`// C# program to find the probability ` `// of an arbitrary positive divisor of ` `// Xth power of 10 to be a multiple of ` `// Yth power of 10 ` `using` `System; ` `class` `GFG{ ` ` ` `// Function to calculate and print ` `// the required probability ` `static` `void` `prob(` `int` `x, ` `int` `y) ` `{ ` ` ` ` ` `// Count of potential divisors ` ` ` `// of X-th power of 10 which are ` ` ` `// also multiples of Y-th power ` ` ` `// of 10 ` ` ` `int` `num = Math.Abs(x - y + 1) * ` ` ` `Math.Abs(x - y + 1); ` ` ` ` ` `// Count of divisors of X-th ` ` ` `// power of 10 ` ` ` `int` `den = (x + 1) * (x + 1); ` ` ` ` ` `// Calculate GCD ` ` ` `int` `gcd = __gcd(num, den); ` ` ` ` ` `// Print the reduced ` ` ` `// fraction probability ` ` ` `Console.Write(num / gcd + ` `"/"` `+ ` ` ` `den / gcd + ` `"\n"` `); ` `} ` ` ` `static` `int` `__gcd(` `int` `a, ` `int` `b) ` `{ ` ` ` `return` `b == 0 ? a : __gcd(b, a % b); ` `} ` ` ` `// Driver code ` `public` `static` `void` `Main(` `string` `[] args) ` `{ ` ` ` `int` `X = 2, Y = 1; ` ` ` ` ` `prob(X, Y); ` `} ` `} ` ` ` `// This code is contributed by AnkitRai01 ` |

*chevron_right*

*filter_none*

**Output:**

4/9

**Time Complexity:** O(log(N))

## Recommended Posts:

- Random number generator in arbitrary probability distribution fashion
- Minimum Possible sum of digits in a positive multiple of N
- Number of integral solutions of the equation x1 + x2 +.... + xN = k
- Number of non-negative integral solutions of a + b + c = n
- Number of non-negative integral solutions of sum equation
- Count Integral points inside a Triangle
- Trapezoidal Rule for Approximate Value of Definite Integral
- Number of integral solutions for equation x = b*(sumofdigits(x)^a)+c
- Find the integral roots of a given Cubic equation
- Max occurring divisor in an interval
- Smallest divisor D of N such that gcd(D, M) is greater than 1
- Program for finding the Integral of a given function using Boole's Rule
- Count of integral coordinates that lies inside a Square
- Find integral points with minimum distance from given set of integers using BFS
- Generating numbers that are divisor of their right-rotations
- Sum of greatest odd divisor of numbers in given range
- Smallest prime divisor of a number
- Maximum sum after repeatedly dividing N by a divisor
- Find elements in a given range having at least one odd divisor
- Find the k-th smallest divisor of a natural number N

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.