import math


def get_g_val(tasks, L):
    """
    Get the g-value product for the given periodic task set.

    Parameters
    ----------
    tasks : list of pSyCH.task.Periodic
        Set of periodic tasks, for which the g-value needs to be computed.
    L : float
        End time limit for computing the g-value

    Returns
    -------
    float
        g-value for the task set.

    """
    g_val = 0
    for task in tasks:
        g_val += (math.floor((L + task.t - task.d)/task.t)*task.c)
    return g_val