@staticmethod
def get_root_and_key(n):
    """
        Return square root expansion root and key for square root of n

        >>> SqrtExpansion.get_root_and_key(24)
        (4, (1, 8))
        """
    root = int(n ** 0.5)
    a_0 = epsilon_0 = int(n ** 0.5)
    gamma_0 = n - epsilon_0 ** 2
    a, epsilon, gamma = a_0, epsilon_0, gamma_0
    expansion = []
    while True:
        a = (int(n ** 0.5) + epsilon) // gamma
        epsilon = a * gamma - epsilon
        gamma = (n - epsilon ** 2) // gamma
        expansion.append(a)
        if epsilon == epsilon_0 and gamma == gamma_0:
            break
    return root, tuple(expansion)
