This project includes the implementation of the Iranian National Code validation algorithm in various programming languages. Each file contains a function that takes a national code as input and checks its validity.
The Iranian National Code validation algorithm is as follows:
- Remove non-numeric characters from the input.
- Check the length of the code (it should be between 8 to 10 digits).
- Standardize the code to 10 digits by adding leading zeros.
- Checking for repeating digits (e.g., 1111111111 is invalid).
- Extract the control digit (the last digit).
- Calculate the weighted sum of the digits (weights from 10 to 2).
- Calculate the remainder and the control digit.
- Compare the calculated control digit with the extracted control digit.
Examples for each file are written inside the respective file.
- [Sina Jalalvandi]
This project is licensed under the MIT License. See the LICENSE file for more details.