If two distinct integers a and b are picked from { 1, 2, 3, 4, .... 100 } and multiplied, what is the probability that the resulting number has exactly 3 factors ?
1. Combination of 2 numbers
Pick up 2 distinct integers.
Combinations = (100 × 99) / 2
n = 100
m = n-1
All_combinations = (m*n)/2
All_combinations
4950.0
2. Triplet combinations
Number 1 has only one factor.
Each integer has '1' and the number itself as factor. It is minimum 2 factors.
The square root of the number should be the only other factor, otherwise there would be 4 factors, not 3 required.
Number of squares of prime numbers from 1 to 100 that have exactly 3 factors are 4, 9, 25, and 49. It is 4 required combinations (triples).
4: 1, 2, 4
9: 1, 3, 9
25: 1, 5, 25
49: 1, 7, 49
def isPrime(n):
i = 2
while i * i <= n:
if n % i == 0:
return False
i += 1
return True
def numbersWith3Divisors(n):
print("Numbers with 3 divisors : ")
i = 2
while i * i <= n:
if (isPrime(i)):
if (i * i <= n):
print(i * i, end = " ")
i += 1
numbersWith3Divisors(n)
Required_combinations = 4
3. Probability
Probability = Required_combinations / All_combinations
Probability = 4 / (( 100 × 99) / 2) = 2 / (25 × 99 )
Probability = Required_combinations / All_combinations
Probability*100
0.0808080808080808
Resources:
https://gmatpractice.q-51.com/hard-math-gmat-sample-questions/gmat-maths-questions.shtml
https://stackoverflow.com/questions/51166586/what-is-the-more-elegant-way-of-finding-combinations-in-a-list
https://learnetutorials.com/python/programs/pythagorean-triples-range
https://www.geeksforgeeks.org/numbers-exactly-3-divisors/
Comments