ISBN 1-3-Sum
InterviewTime limit1sMemory limit128 MB
Given the last three digits of an ISBN starting with 9780921418, compute the 1-3-sum and print it.
- Level
Easy2 of 10
- Topics
- Math, Implementation, Simulation
- Solved
- No attempts yet
Problem
The International Standard Book Number (ISBN) is a 13-digit code that identifies a book. These codes have a special property that lets you detect whether the number was written down correctly.
The 1-3-sum of a 13-digit number is obtained by multiplying its digits alternately by 1 and 3 and then adding the results. Counting from the first digit, the odd-positioned digits are multiplied by 1 and the even-positioned digits by 3.
For example, the 1-3-sum of the number is computed as
The special property of an ISBN is that its 1-3-sum is always a multiple of 10.
Write a program that computes the 1-3-sum of a 13-digit number. To reduce the amount of typing, you may assume that the first ten digits are always , exactly as in the example above. Your program reads the last three digits and prints the 1-3-sum.
Input
The last three digits are given on three separate lines, one digit per line. Each digit is an integer between and inclusive.
Output
Print the 1-3-sum in the format The 1-3-sum is X, where X is the computed 1-3-sum.