Given two numbers X and Y, the task is to find the probability that an arbitrary positive divisor of 10X is an integral multiple of 10Y.
Note: Y should be <= X.
Input: X = 2, Y = 1
Positive divisors of 102 are 1, 2, 4, 5, 10, 20, 25, 50, 100. A total of 9.
Multiples of 101 upto 102 are 10, 20, 50, 100. A total of 4.
P(divisor of 102 is a multiple of 101) = 4/9.
Input: X = 99, Y = 88
A = 1099, B = 1088
P(divisor of 1099 is a multiple of 1088) = 9/625
Pre-requisites: Total number of divisors of a number
In order to solve the problem, we need to observe the steps below:
- All divisors of 10X will be of the form:
(2 P * 5 Q), where 0 <= P, Q <= X
- Find the number of Prime factors of 10X
10X = 2X * 5X
- Hence total number of divisors of 10X will be: ( X + 1 ) * ( X + 1 ).
- Now, consider all multiples of 10Y which can be potential divisors of 10X. They are also of the form:
( 2 A * 5 B ), where Y <= A, B <= X.
- So, count of potential divisors of 10X which are also multiples of 10Y is ( 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:
Time Complexity: O(log(N))
- Random number generator in arbitrary probability distribution fashion
- Minimum Possible sum of digits in a positive multiple of N
- Count Integral points inside a Triangle
- Number of Integral Points between Two Points
- Number of non-negative integral solutions of a + b + c = n
- Trapezoidal Rule for Approximate Value of Definite Integral
- Number of integral solutions of the equation x1 + x2 +.... + xN = k
- Number of non-negative integral solutions of sum equation
- Number of integral solutions for equation x = b*(sumofdigits(x)^a)+c
- 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
- Find initial integral solution of Linear Diophantine equation if finite solution exists
- Find the integral roots of a given Cubic equation
- Generate all integral points lying inside a rectangle
- Greatest divisor which divides all natural number in range [L, R]
- Max occurring divisor in an interval
- Smallest divisor D of N such that gcd(D, M) is greater than 1
- Generating numbers that are divisor of their right-rotations
- 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 firstname.lastname@example.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.