信用卡测试混乱 [英] Credit card test confusion

查看:98
本文介绍了信用卡测试混乱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该根据这些规则找出cc数字是否有效:



将每隔一位数字乘以2,从数字倒数第二位开始数字,然后将这些产品的数字加在一起。



将总和加到未乘以2的数字之和。



如果总的最后一位数是0(或者更正式地说,如果总模数10与0一致),则该数字有效!



当我手工操作时,我不会对这些数字有效......但它们是(来自解决方案网站)。我可以看看它是如何正确完成的吗?



I am supposed to find if cc numbers are valid based on these rules:

Multiply every other digit by 2, starting with the number’s second-to-last digit, and then add those products' digits together.

Add the sum to the sum of the digits that weren’t multiplied by 2.

If the total’s last digit is 0 (or, put more formally, if the total modulo 10 is congruent to 0), the number is valid!

When I work-it-out by hand, I dont get valid for these numbers... but they are (from the solutions site). Can I see how its done correctly?

371449635398431

5105105105105100

4111111111111111

4012888888881881





谢谢



我尝试了什么:



我在纸上做了。我尽力遵守规则。我确实在其他数字上做到了,但不是这些。



Thanks

What I have tried:

I worked it out on paper. I tried my best to follow the rules exactly. I did get it right on other numbers, but not these.

推荐答案

让我们对第一个输入代码执行操作:



Let's perform the operation on the first input code:

371449635398431

every other digit (starting from second-to-last)
3 8 3 3 9 4 7
doubled and summed up
6 + 16 + 6 + 6 + 18 + 8 + 14 = 74
remaining digits (starting from the left), summed up
3 + 1 + 4 + 6 + 5 + 9 + 4 + 1 = 33

Total = 107





所以,至少我可以确认根据所描述的规则,第一个输入代码应该被拒绝。



要么我们是对的(并且'解决方案网站'错了),要么我们'错误(计算错误)或报告的规则被误写(或被误解)。





[update]

根据本网站信用卡号码生成器&am磷; Validator - FreeFormatter.com [ ^ ]此类输入是有效的信用卡号。但是遵循的规则有点不同,即它们遵循 Luhn 算法。由于算法在同一网站上有详细描述,我建议你看一下。

[/ update]



So, at least I can confirm that, according to the rules depicted, the first input code should be rejected.

Either we're right (and the 'solution site' is wrong) or we're wrong (bad computation) or the reported rules are miswritten (or misunderstood).


[update]
According to this site Credit Card Number Generator & Validator - FreeFormatter.com[^] such input is a valid credit card number. However the rules followed are a bit different, namely they follow the Luhn algorithm. Since the algorithm is well described in the same site, I suggest you to have a look at it.
[/update]


这篇关于信用卡测试混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆