I am writing a high school maths thesis, I use the fpp2 forecasting package. The issue is simple, I gave in input, the forecast function gave me the output for n periods in the future, I know the formula, but how can I see how R calculated my data?
The answer to your question is in the docs and the source code.
To answer your question more generally, you'll want to look up the function you applied in the docs. There, package authors usually cite their sources. With the function name (and a bit of knowledge about how R works), you can also track down the function in the repo, to see exactly how that formula is applied.