def sm2(quality: int, interval: int, repetitions: int, easiness: float) -> tuple[int, int, float]:
    """SuperMemo-2 Algorithm (SM-2).

    Args:
        quality: A performance measure ranging 0 (complete blackout) to 5 (perfect response).
        interval: The number of consecutive correct answers (quality >= 3).
        repetitions: Inter-repetition interval after the n-th repetition (in days).
        easiness: Easiness factor reflecting the easiness of memorizing and retaining a given item in memory.

    Returns:
        The new interval, repetition number, and easiness.

    Algorithm SM-2, (C) Copyright SuperMemo World, 1991.

    https://www.supermemo.com
    https://www.supermemo.eu
    """
    if quality < 3:  # Incorrect response.
        interval = 1
        repetitions = 0
    else:  # Correct response.
        # Set interval.
        if repetitions == 0:
            interval = 1
        elif repetitions == 1:
            interval = 6
        else:
            interval = round(interval * easiness)

        repetitions += 1

    # Set easiness.
    easiness += 0.1 - (5 - quality) * (0.08 + (5 - quality) * 0.02)
    if easiness < 1.3:
        easiness = 1.3

    return interval, repetitions, easiness