The person should have been issued with a National Insurance number in their late teens/early 20s. If they don't have an NI number or have lost their paperwork, they can request an NI number from the Pensions department.
See here: https://www.gov.uk/find-national-insurance-number
Once they have an NI number, they can register for access to the Government Gateway here:
https://www.gov.uk/check-national-insurance-record
Then they can check their NI record.
If they are 40, they may have been credited three years of NI credits for the years in which they were 16, 17 and 18.
If they have been credited for these three years, that means they would need a further 7 years of Voluntary Contributions (or 7 years of credited contributions in order) to qualify for any state pension.
(Each additional year after 10 years increases the monthly pension by 1/35 of the full state pension.)
For someone aged 40, the state pension retirement age is predicted to be 68 and they need 35 "qualifying years" to be entitled to the full state pension.
We had this situation with our adult child. He has had a chronic medical condition since the age of 12 and has been unable to work. We have chosen to support him financially and provide his care. He has not claimed any benefits since since reaching school leaving age.
Last year, he registered for access to the Government Gateway. He had been issued with a NI number in his teens/20s. He was able to check his NI record and established that he had been credited with 3 years of contributions for the years in which he was 16, 17 and 18.
He established that he would need 35 "qualifying years" of contributions for the full state pension. So he applied to start paying monthly contributions from April this year.
If he continues to pay for these until he reaches state pension age, he would still be 3 years short of 35 years of Voluntary Contributions. So he elected to pay for 3 years of back contributions through HMRC, as a one-off payment, and also set up a direct debit mandate to pay monthly contributions going forward.
Because of the rules for paying missing years before the end of financial year 5 April 2025, he was able to choose to pay the 3 cheapest years. (Normally you can only pay back missing years for up to 6 previous years.)
The Martin Lewis financial site is very helpful about NI contributions, Voluntary Contributions and paying back missing years and the Pensions departments are friendly and helpful, too.