How Flashcard Apps Know When You Are About to Forget
How flashcard apps know when you are close to forgetting an answer and adjust study gaps automatically from one day to several weeks.
Why Reading Everything Twice Rarely Sticks
When revising for university exams or learning syntax in a new language, reviewing a card you already know well ten minutes after getting it right wastes energy. On the other hand, waiting a month before revisiting a tricky definition guarantees you forget it completely.
Spaced repetition solves this timing problem automatically by stretching the gap after every successful recall and shrinking it back down as soon as you hesitate.
Four Simple Rules Behind SM-2
When building sm2-study-planner, I implemented the classic SM-2 scheduling algorithm. Despite sounding mathematical, every review card only tracks three tiny numbers:
- Streak: how many times in a row you remembered the answer cleanly.
- Ease score: how sticky or difficult the card appears to be (starting at
2.5). - Next gap: how many days to wait before asking again.
Each time you quiz yourself, you score how easy it felt from 0 (blanked completely) up to 5 (answered straight away):
- First time right (
score 3+): wait 1 day. - Second time right in a row: wait 6 days.
- Third time and beyond: multiply the previous gap by your Ease score (
6 × 2.5 = 15 days, then38 days, and so on). - Any score below
3: reset the streak back to zero and ask again tomorrow, while gently lowering the Ease score so harder cards appear slightly more often.
def next_interval_days(streak: int, ease: float, previous_days: int, quality: int) -> int:
if quality < 3:
return 1
if streak == 1:
return 1
if streak == 2:
return 6
return round(previous_days * ease)Deterministic Tools Work Best
Notice how little code this takes. There is no black-box recommendation engine guessing what you might remember — just transparent arithmetic that treats every card fairly and explains to the user why tomorrow's study queue contains ten minutes of work instead of three hours.