Giter Site home page Giter Site logo

codemeli's Introduction

اعتبار سنجی کد ملی با پایتون

EN:
Iranian National Code Validation Algorithm
Here we have a detailed algorithm for validating the national code and implemented it in Python

  • The national code can be 8 digits or 9 or 10 digits
  • If the length of the national code is 8, we add 2 zeros to the beginning
  • If the length is 9, we add a zero to the beginning
  • If all the indexes of the national code are multiplied by their place value, then added together and then divided by the remainder, they must be equal to the last digit of the national code.
  • Or we subtract the number 11 in response to the above statement and compare it with the last index of the national code string. If it is correct, then the national code is also correct.

I may not have been able to explain exactly what I meant, but in the code you can see everything clearly.

FA:


الگوریتم اعتبارسنجی کد ملی ایران
در اینجا ما یک الگوریتم دقیق برای اعتبار سنجی کد ملی و پیاده سازی آن در پایتون داریم

  • کد ملی می تواند 8 رقمی یا 9 یا 10 رقمی باشد
  • اگر طول کد ملی 8 باشد، 2 صفر به ابتدا اضافه می کنیم
  • اگر طول 9 باشد به ابتدا یک صفر اضافه می کنیم
  • اگر تمامی اندیس های کد ملی در ارزش مکانی خود ضرب شود سپس باهم جمع شوند و سپس تقسیم باقیمانده 11 شوند باید با آخرین رقم کد ملی برابر باشند
  • یا عدد 11 را در جواب عبارت بالا منهی میکنیم و با آخرین اندیس از رشته کد ملی مقایسه میکنیم اگر درست بود ، آنگاه کد ملی نیز صحیح است

** شاید نتوانسته باشم دقیق توضیح دهم و منظور را برسانم ، اما در کد میتوانید همه چیز را به وضوح ببینید **
our tg channel: https://t.me/AppDuny
my pv in tg: https://t.me/DeAref

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.