Multiply the 9 digits by the weights 3, 7, 1, 3, 7, 1, 3, 7, 1 and add them up: the number is valid when the total is a multiple of 10. To find the ninth digit, add only the first 8 products and take 10 minus the remainder after dividing by 10 (0 if the remainder is 0). In 111000025 the first 8 products add up to 3+7+1+0+0+0+0+14 = 25, 5 short of 30, so the ninth digit is 5.