import math


def calculate_num_Grover_iters(n, k):
    """
    Calculate optimal number of Grover search iterations

    n: number of qubits
    k: number of solutions
    """
    num_iters = (math.pi / 4) * math.sqrt(2 ** n / k)
    return math.floor(num_iters)