When you check your NI record, it'll show any gap years. For every gap year, there'll be a 'more details' header where you'll be able to see the size of your shortfall and how much it'll cost to fill. A gap year does not necessarily mean you're missing 52 weeks – in some cases, you might only have to buy one or two weeks' worth of contributions.
Why employees might need to pay for partial years
For a full qualifying year of NI contributions, you need to earn at least £6,396 a year from a single employer – however only weeks where you've earned at least £123 (the 'lower earnings limit') count towards this total. So employees could find they fall short of a qualifying year – sometimes by just one or two weeks – even though they might've earned more than £6,396 that year.
For example: Ben earns £200 a week for 31 weeks and then £100 per week for the remaining 21 weeks. In total, he's earned £8,300. However, when he subtracts the weeks where he didn't earn at least £123 per week, his qualifying earnings total £6,200. This is £196 short of the £6,396 threshold for a full qualifying year. The way that HMRC calculates Ben's shortfall means if he buys two weeks' worth of voluntary class 3 national insurance he can turn this 'gap year' into a full qualifying year.
Why self-employed people might need to pay for partial years
If you're self-employed and your profits were less than the Small Profits Threshold (currently £6,725), you wouldn't automatically pay any NI contributions and typically you'd need to pay voluntarily for Class 2 contributions for every week you were self-employed for the year to become a 'qualifying year' for state pension purposes.
However, you might've earned NI credits in other ways (see step 2 above), therefore would only need to pay for the weeks in shortfall. As mentioned above, when you check your NI record, the details of all credits earned and any shortfall for that year will be displayed.
How HMRC calculates partial years
HMRC subtracts what you've earnt over the year (but only in weeks above the £123 threshold) from the £6,396 threshold. Then it divides the difference by £123 (for example, one week's qualifying earnings) to give the number of weeks shortfall, which is then rounded up to a whole number of weeks.
For example: Using the same example as above, Ben is £196 short of the £6,396 earnings threshold for a full qualifying year. So 196 is divided by 123 to get 1.6, which is rounded up to 2. Ben needs to buy two weeks of voluntary class 3 national insurance contributions for his 'gap year' to become a full qualifying year. The cost of one week for the 2022/23 tax year is £15.85, so Ben would need to pay £31.70 to plug his shortfall.