Your residence period is reckoned from the date you were granted legal residence in Norway. This can be the date when you came to Norway or the date when you applied for a registration certificate or residence card.
If you have stayed in Norway with the right of residence without having registered, you must substantiate how long you have been here with the right of residence and that you have had the right of residence here throughout this period.
If you have stayed abroad for two months or less during one calendar year, that will have no bearing on the calculation of your residence period. This means that such stays abroad are regarded as residence in Norway, and the time you have spent abroad will not be deducted. If you stay abroad for more than two months during a calendar year, however, the whole period abroad will be deducted, not just the part that exceeds two months. This is also the case if you were working abroad.
You cannot have stayed abroad for more than two months within one calendar year in the last three years. Since stays of more than two months within one calendar year are deducted from your period of residence, you will not fulfill the requirement to have resided continuously in Norway for the past three years. This applies regardless of whether you have a permanent right of residence or not.