How do I implement the Luhn algorithm?

后端 未结 8 1621
被撕碎了的回忆
被撕碎了的回忆 2020-12-21 09:50

I am trying to create a program to validate 10 to 12 digit long number sequences based on the luhn algorithm, but my program keeps on telling me that every number is invalid

8条回答
  •  半阙折子戏
    2020-12-21 10:12

    You should be subtracting '0' from tmp, not 0. Subtracting 0 returns the ASCII value, which you don't want.

提交回复
热议问题