الگوریتم لان: تفاوت میان نسخهها
محتوای حذفشده محتوای افزودهشده
جز ربات :جایگزینی پیوند قرمز با مترادف فارسی PYTHON (PROGRAMMING LANGUAGE) > پایتون (زبان برنامهنویسی) |
بدون خلاصۀ ویرایش |
||
خط ۱۷:
{| class="wikitable" style="text-align:center"
! Account number
| style="width:1.5em" |
| style="width:1.5em" |
| style="width:1.5em" |
| style="width:1.5em" |
| style="width:1.5em" |
| style="width:1.5em" |
| style="width:1.5em" |
| style="width:1.5em" |
| style="width:1.5em" |
| style="width:1.5em" |
| style="width:1.5em" | x
|-
! Double every other
|
| style="background: #FFA;" |
|
| style="background: #FFA;" |
|
| style="background: #FFA;" |
|
| style="background: #FFA;" |
|
| style="background: #FFA;" |
| x
|-
! Sum of digits
|
|
|
|
|
|
|
|
|
|
|=
|}
{{پایان چپچین}}
رقم
#مجموع ارقام
#در
#رقم آخر را
#
روش
#مجموع ارقام
#رقم
#رقم
#
همه
#همه ارقام را
#مجموع
#اگر مجموع
#
==
<!--
Do not add more code to this article. The CS MOS discourages multiple code samples, as they are rarely of encyclopedic value.
-->
در [[پایتون (زبان برنامهنویسی)|
<source lang="python">
def is_luhn_valid(cc):
num = map(int, str(cc))
return sum(num[::-2] + [sum(divmod(d * 2, 10)) for d in num[-2::-2]]) % 10 ==
</source>
==محاسبه رقم
#
#اگر مجموع به
#در
در [[پایتون (زبان برنامهنویسی)|
<source lang="python">
خط ۱۰۱:
</source>
===
{{چپچین}}
*[http://sites.google.com/site/abapexamples/javascript/luhn-validation Luhn implementations in Javascript]
خط ۱۰۹:
* Ruby: [https://gist.github.com/1182499 Luhn validation], [https://gist.github.com/1409815 Luhn generation]
{{پایان چپچین}}
===
{{چپچین}}
*[http://en.wikipedia.org/w/index.php?title=Bank_card_number&oldid=467587726 شماره
*[http://www.brainjar.com/js/validation/default2.asp Luhn checking bank card numbers]
خط ۱۲۰:
{{چپچین}}
<references/>
*{{US patent|
{{پایان چپچین}}
|