Problem B
CPR Number
Languages
da
en
Danish citizens have a unique personal identification number in the Danish Central Person Register, called the CPR number.
Each CPR number consists of ten digits. The first six digits represent the person’s day of birth. The following four digits are a sequence number.
Until
is divisible by
A publication from the government agency CPR-Kontoret from 1 July 2008 explains the method using the CPR number 070761-4285 as an example.
Validating a number with check digit
The 10 integers
0
7
0
7
6
1
4
2
8
5
multiplied by
their corresponding values
4
3
2
7
6
5
4
3
2
1
yield
which sums to
. Dividing by yields with no remainder. Since
divides without remainder, the test is passed. Otherwise the combination of 10 digits is wrong, or the CPR number does not have a check digit.
Input
A CPR number in the format ddmmyy-kkkk, i.e,
Output
“1” if the CPR Number is valid accoring to the modulo
Sample Input 1 | Sample Output 1 |
---|---|
070761-4285 |
1 |
Sample Input 2 | Sample Output 2 |
---|---|
051002-4321 |
0 |
Sample Input 3 | Sample Output 3 |
---|---|
310111-0469 |
1 |