Skip to content

平成24年度 春期 ITパスポート試験 問100

This question's explanation and your answers so far.

問100
頻出度★★☆

多くの市販の書籍には,書籍を識別するための ISBN(International Standard Book Number)コードが付けられている。ISBN コードは,0~9の数字を使った13桁の記号で構成され,左側から桁を数える。最も左側の桁を1桁目とする。1桁目から12桁目までは,国記号,出版者記号及び書籍固有の記号などが含まれる。 ISBN コードの13桁目(最も右側の桁)はチェック数字と呼ばれる桁である。ISBN コードのチェック数字は,1桁目から12桁目の数字を使って,次の計算方法によって求める。ここで,図1のように1桁目から12桁目の数字を a₁~a₁₂,チェック数字を X とする。 〔チェック数字の計算方法〕 (1) a₁~a₁₂について,奇数桁には1,偶数桁には3の重みを付ける。 (2) a₁~a₁₂の各桁に,それぞれの桁に対応した重みを掛けたものの和 S を求める。   S = a₁×1+a₂×3+a₃×1+…+a₁₂×3 (3) S を10で割った余り R を求める。 (4) 10から R を引いた値をチェック数字 X とする。なお,この値が10になった場合は,チェック数字は0とする。 表計算ソフトを使ってチェック数字を求めることにした。チェック数字を求める次のワークシート中のセル N2に入れる適切な式はどれか。このワークシートは,セル B2~M2に数字を入力することで,繰り返し使うものとする。 (1) セル B1~N1に,ISBN コードの桁数を表す数値を入力する。 (2) セル B2~M2に,ISBN コードの1~12桁を,各セルに1桁ずつ入力する。 (3) セル B3~M3に,ISBN コードの各桁に対応した重みを入力する。 (4) セル B5に,ISBN コードに各桁の重みを掛けたものの合計を求める。 (5) セル B6に,剰余関数を使った次の式を入力する。   剰余(B5,10) (6) セル N2に,チェック数字を求める式を入力する。

ABCDEFGHIJKLMN
1桁12345678910111213
2ISBN コード978400004321
3重み131313131313
4
5和(S)68
6剰余(R)

注記 網掛けの部分は,表示していない。 図3 チェック数字を求めるワークシート

出典 平成24年度 春期 ITパスポート試験 問100
解説

問 100

  • Incorrectア

    10-B6 does return the correct value when the remainder R is 1 to 9, so at first glance it looks fine, but when R=0 it returns 10, a two-digit value. The check digit is the single digit that goes into the 13th position of the ISBN, so 10 is impossible; the correct value is 0. This worksheet is premised on being used repeatedly by swapping the numbers in B2 to M2, so an input whose sum is a multiple of 10 (R=0) will naturally occur. A formula that is correct for only one particular example, but not for every input, cannot be called an appropriate formula.

  • Incorrectイ

    B6-10 subtracts in the wrong direction. B6 is the result of MOD(B5,10), so it always falls in the range 0 to 9, and subtracting 10 from it always gives a negative value between −10 and −1. In the example in the figure as well, 8-10=−2, which makes no sense as a check digit. A check digit is based on the idea of the complement to 10, that is, subtracting the remainder from 10; this formula swaps the minuend and the subtrahend, which is a clear error.

  • Incorrectウ

    10-MOD(B6,10) applies the remainder function in the wrong place. B6 is already the result of MOD(B5,10) and lies in the range 0 to 9, so applying MOD(B6,10) to it again does not change the value; it is simply B6 itself. In other words, this formula ends up being exactly the same calculation as ア, 10-B6, and it carries the same flaw of returning 10 when R=0. What needs to have the remainder taken is not B6, but 10-B6 after the subtraction is done.

  • エ

    正解 The correct answer is エ, MOD(10-B6,10). First, follow what the worksheet in Fig. 3 actually computes. The weights in row 3 alternate as 1,3,1,3,… starting from column B, and the Sum (S) in B5 is the total of each digit of the ISBN code multiplied by its weight. Checking with the values in the figure: 9×1+7×3+8×1+4×3+0×1+0×3+0×1+0×3+4×1+3×3+2×1+1×3 = 9+21+8+12+0+0+0+0+4+9+2+3 = 68, which matches the B5=68 shown in the figure. Next, the Remainder (R) in B6 is MOD(B5,10) as instructed in (5), that is, MOD(68,10)=8. The check digit in the 13th position of an ISBN is the value obtained by subtracting the remainder of the sum divided by 10 from 10, but there is one pitfall here. When the remainder R is 0, 10-R becomes 10, which cannot work as a check digit that has to be a single digit (the correct value is 0). This worksheet is explicitly described as being used repeatedly by re-entering numbers into cells B2 to M2, so an ISBN code that makes R=0 must also be taken into account. Therefore, if the result of 10-B6 is divided by 10 once more to take the remainder, then when R is 1 to 9 it returns 10-R (=9 to 1) unchanged, and only when R=0 does it become MOD(10,10)=0, correctly giving 0. The formula that satisfies both of these in a single expression is エ, MOD(10-B6,10). In the example in the figure, MOD(10-8,10)=MOD(2,10)=2, so the check digit entered into N2 is 2.

ここがポイント
  • How a check digit is computed — multiply each digit by its weight and add them up (S), take the remainder of that sum divided by the modulus (10 here) (R), and subtract the remainder from the modulus to produce the single check digit. In ISBN-13 the weights alternate as 1,3,1,3,…
  • Using the remainder (MOD) function to eliminate a boundary case — 10-R becomes 10 only when R=0, and then it no longer fits in a single digit, so apply MOD(…,10) once more to the whole result to bring it into the range 0 to 9. A spreadsheet formula is judged not by one particular set of data, but by whether it holds for every input across repeated use.
用語
解答問100エ
Practise this question

Your answers