Write a function which, given the first 12 digits of an ISBN-13 code, will calculate the entire ISBN via calculating and appending an appropriate check digit.
Your function's input is a string containing the first 12 digits of the ISBN. Its output is a string containing all 13 digits.
Formal specification
Write a function which, when given a string s consisting entirely of exactly 12 decimal digits (and no other characters), returns a string t with the following properties:
- t consists of exactly 13 decimal digits (and no other characters);
- s is a prefix of t;
- the sum of all digits in odd positions in t (i.e. the first, third, fifth, etc.), plus three times the sum of all digits in even positions in t (i.e. the second, fourth, sixth, etc), is a multiple of 10.
Example / test case
Input
978030640615
Output
9780306406157
Victory condition
As a code-golf challenge, the shortest answer wins.