import math


def calculate_ideal_amount_of_iterations(n, k=1):
    """
    Calculates the ideal amount of Grover's iterations required for n qubits
    (assuming k solutions). See:
    https://en.wikipedia.org/wiki/Grover%27s_algorithm#Extension_to_space_with_multiple_targets
    
    If there are no solutions, no iterations are needed (but actually those iterations wouldn't
    matter as they would just scramble the states)

    Args
    --------------------
    n: amount of qubits to be diffused
    k: amount of solutions
    """
    # return closest integer to the ideal amount of calculations
    return round((math.pi/4)*( math.sqrt(2**n/k) )) if k>0 else 0