<jupyter_start><jupyter_text>Question25. We call the pair (m,n) of positive integers a happy pair if the greatest common divisor of m and n is a perfect square. For example, (20, 24) is a happy pair because the greatest common divisor of 20 and 24 is 4. Suppose that k is a positive integer such that (205800,35k) is a happy pair. The number of possible values of k with k ≤ 2940 is(A) 36 (B) 28 (C) 24 (D) 30 (E) 27  Python SolutionFirst, we need to define a function that computes the greatest common divisor of two position integers.<jupyter_code>def gcd(x, y):
    assert type(x) is int
    assert type(y) is int
    assert x > 0
    assert y > 0
    
    a = max(x, y)
    b = min(x, y)
    r = a % b
    
    while r > 0:
        a = b
        b = r
        r = a % b
    
    return b
gcd(20,24)<jupyter_output><empty_output><jupyter_text>Or, we can use the built-in `math.gcd` function.<jupyter_code>import math

math.gcd(20, 24)<jupyter_output><empty_output><jupyter_text>An integer `x` is a perfect square if and only if it is the square of an integer `y`, so `x == y * y`. Therefore `y == int(sqrt(x))`.<jupyter_code>def is_perfect_square(x):
    y = int(math.sqrt(x))
    return x == y * y

is_perfect_square(25)
is_perfect_square(24)
def is_happy_pair(m, n):
    return is_perfect_square(gcd(m, n))

is_happy_pair(20, 24)
solutions = [k for k in range(1, 2941) if is_happy_pair(205800, 35 * k)]
solutions
len(solutions)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1039671682626539, 'fraction_numerical': 0.04445964432284542, 'mean_word_length': 3.5434782608695654, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '345243', 'license': 'MIT', 'n_tokens_mistral': 589, 'n_tokens_neox': 524, 'n_words': 200, 'path': 'Meeting Notes/2020/2020-05-09/2020 Pascal Contest - Question 25.ipynb', 'repo_name': 'agryman/sean', 'size': '1462'}