Problem Statement
The government of India has launched the UID project which aims to give a Unique
Identification number to each Indian. The number is a randomly generated 16 digit number. To
detect errors when typing in this number, we propose to use the last digit as a checksum.
Following are the rules to generate and validate the checksum :-
1. Starting from left to right, sum all odd numbered digits and multiply the sum by 3
2. Sum all even numbered digits and multiply the sum by 7
3. Add the two sums from step 1 and step 2.
4. Divide the number in step 3 by 10 and take the remainder(modulo operation).
5. Subtract the number obtained in step 4 from 10. The result is the check digit.
Lets say that the number is 4583 4323 8143 257(last digit is for check digit)
Sum of odd numbered digits :- 4 + 8 + 4 + 2 + 8 + 4 + 2 + 7= 39 * 3 = 117
Sum of even numbered digits :- 5 + 3 + 3 + 3 + 1 + 3 + 5 = 23 * 7 = 161
Total sum = 117 + 161 = 278
Remainder after dividing 278 by 10 = 2
Therefore, the check digit is 10 - 2 = 8. So the final number is 4583 4323 8143 2572
Similarly, the check digit for 765381206010321 is 7.
Hence, the final number is 7653812060103217.
Write a program to check if the UID number entered is valid or not.
You are free to use a programming language of your choice.