def multJ(J,M):
    """
    Calculates the branching multiplicity of J to M.  Multiplicity is 1 if M if valid projection and 0 if not. 
    """
    mult=0
    if abs(M)<=J:
        #check if both are half integers or integers
        if (2*J)%2==(2*M)%2:
            mult=1
    return mult