look for. You have ended my 4 day lengthy hunt! God Bless

you man. Have a great day. Bye ]]>

If you are interested, I fixed the problem by adding one more calculation.

I’ve seen this in other places too. This problem is from the algorithm description:

Step 3: Subtract from next higher number ending in zero. 70 – 67 = 3 Check digit = 3 NPI with check digit = 1234567893

But it doesn’t really take into account the fact that the “next higher number ending in zero” will actually result in a check digit of 10 when the current number already ends in 0. (ex: Starting at 60, the next higher digit ending in zero would be 70 and 70-60 = 10)

To fix it, I basically put in one additional calculation. Using pseudo code:

Original: 10 – (newMod mod 10)

New: (10 – (newMod mod 10)) mod 10

I think for the formula posted in this site, the new formula would look like this:

var checkDigit = (10 – newMod) % 10;

The extra mod 10 on the whole formula will always result in the original number as long as the original number is less than 10. If the original number=10, then (10 mod 10) = 0 and gives us the correct check digit calculation. Going back to the original example ((70-60) mod 10) = 0

]]>