An off-by-one error gets an answer wrong by exactly one. In memory work it nearly always comes from forgetting that addresses start at 0, or that a range includes both ends.
The three places it bites:
- Last address. N words have addresses 0 to N − 1. A 4K memory ends at 4095 (FFF₁₆), not 4096.
- Size of a range. From S to E inclusive there are E − S + 1 words, not E − S.
- End of a block. N words starting at S end at S + N − 1, not S + N.
The classic picture is a fence: a 10-meter fence with posts every meter needs 11 posts. Count the posts (addresses), not the gaps between them.
A quick self-check for memory: the last address of a whole memory, or of a block starting at a multiple of its size, is all 1s in its low bits, so it ends in F digits in hex (possibly after a leading 1, 3 or 7). If your end address is a round number like 4000₁₆, you've probably landed on the next block's first address. See address range.