Calculating the check digit of IMEI by Luhn algorithm

The check digit of IMEI is required to check the correctness of the entered IMEI number.
If the check digit does not match the calculated one, then the IMEI number is entered incorrectly.

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1. Add all digits in odd positions.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
=
 
2. Replace the digits in even places by the formula:
0=>0, 1=>2, 2=>4, 3=>6, 4=>8, 5=>1, 6=>3, 7=>5, 8=>7, 9=>9 and summarize them.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
=
 
3. Summarize the two results.
+
=
4. In case the sum of digits ends in 0, 0 is the check digit.
Otherwise, the checksum is equal to the number that needs to be added to the result to get the next highest "round" number.
Check digit
+
=
 
 
 
 
 
 
 
 
 
 
 
 
 
 
=