Post Reply 
checkdigit calculation for HP-17b
07-26-2015, 07:29 PM
Post: #8
RE: checkdigit calculation for HP-17b
Hello Don,

Interesting algorithm and HP-17B equation!

Here we happy taxpayers have a personal 11-digit number known as CPF, the last two of which being the checking digits. Starting with your SOD (sum of digits) equation, it wasn't difficult to obtain a 17Bii equation to compute them:

C=10*MOD(MOD(0*L(T:0)+Σ(I:1:9:1:0*L(T:G(T)+I*MOD(N:10))+(10-I)
*MOD(N:10)+0*L(N:IDIV(N:10))):11):10)+MOD(MOD(G(T):11):10)

No attempt have been made to optimize it, though.

123 456 789 --> 0 (they should be 00, actually)
976 431 258 --> 64
777 777 777 --> 77

The interesting part is that I didn't need to look at the linked Wikipedia article before writing the equation, as I knew the algorithm since I was 14 or 15, when I didn't have access to computers or even calculators, programmable or not. My father taught that to me. He was a policeman and once had a report returned because of missing or wrong checking digits. Since the number holder was not readily available, he tried and figured out the algorithm by himself, using pencil and paper. He was no computer or math expert!

Gerson.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: checkdigit calculation for HP-17b - Gerson W. Barbosa - 07-26-2015 07:29 PM



User(s) browsing this thread: 5 Guest(s)