You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, i took this random CPF (Brazilian identification number) from a generator:
251.014.990-30
How to calculate
The first 9 digits of the CPF are used to determine the last 2 digits, separated by a hyphen.
Basically, you perform a multiplication in descending order with the numbers, and then add up all the results. The multiplication starts with the number 10 to find the first digit:
remembering that we only use the first nine digits to perform the calculation
2 5 1 0 1 4 9 9 0
x10 9x x8 x7 x6 x5 x4 x3 x2
So, doing this, we will get: 20 45 8 0 6 20 36 27 0
Adding these results, we get = 162.
So now, with this number in hand, we use the following formula:
11 - (162 % 11)
This will result in, guess what, 3.
With this, we repeat the same multiplication calculation, but now including the 3 at the end and also starting to multiply by 11.
2 5 1 0 1 4 9 9 0 3
x11 x10 x9 x8 x7 x6 x5 x4 x3 x2
So, doing this again, we will get: 22 20 9 0 7 24 45 0 6
Now, adding everything again, we have a total of = 133
So, we do the same calc as we did before
11 - (133 % 11)
Applying our calculation again, we will see that it results in 10.
However, there is a detail to be noted: a CPF can only have 2 digits after the hyphen, so there is a rule that if the result of this formula is greater than 9, it becomes zero.
therefore in second digit we get 3
So we have the number 3, and 0, lets add it to our 9 digits, and we will get the same cpf from the beginning, confirming the accuracy of the calculation