Wikipedia:Reference desk/Archives/Mathematics/2020 September 29

= September 29 =

Arithmetic
What is a shortcut method to determine whether a number is divisible by 7? — Preceding unsigned comment added by 108.77.21.116 (talk) 20:18, 29 September 2020 (UTC)


 * See Divisibility rule. However, it's often just as simple to just try to divide by 7 and see if you get a remainder of 0 or not than to actually carry out any of the methods listed. –Deacon Vorbis (carbon &bull; videos) 20:30, 29 September 2020 (UTC)


 * For really long numbers, a method that, I think, is faster by hand, and in any case less likely to go astray by a calculation error, is to split up the number in groups of three digits (starting from the end) and alternately adding and subtracting these. For example, for the number 1234567890123456789:
 * Split in groups of three: 1 234 567 890 123 456 789;
 * Alternate + and −: +1−234+567−890+123−456+789 = −100;
 * The number 100 is not divisible by 7, so neither is 1234567890123456789.
 * The same sum can also be computed by rearranging the terms, which may be easier:
 * (1+567+123+789)−(234+890+456) = 1480−1589 = −100.
 * Another example, 12345678901234567890123456789.
 * +12–345+678–901+234−567+890−123+456−789 = −455;
 * The number 455 is divisible by 7, so the 29-digit number above is too.
 * This works because 1001 is divisible by 7. It is also divisible by 11 and 13 (1001 = 7×11×13), so the method works for these as well. For example, −455 is also divisible by 13, and therefore the large number is divisible by both 7 and 13. --Lambiam 23:36, 29 September 2020 (UTC)


 * You can also do the splitting in groups of three digits starting from the front, provided you pad the last group with digits 0 at the end to reach a full three digits. For example, for 12345678901234:
 * +123−456+789−012+34 0 = (123+789+340)−(456+012) = 1252−468 = 784 = 7×112,
 * so 12345678901234 is divisible by 7. --Lambiam 19:55, 30 September 2020 (UTC)


 * You can also compute the number modulo 7, and with the equals sign denoting equality modulo 7, use that 10 = 3, 100 = 10^2 = 3^2 = 9 = 2, and as also mentioned above by Lambiam, 1000 = 10*100 = 3*2 = 6 = -1. E.g. that 455 is divisible by 7 follows directly from 455 = 5 + 3*5 + 2*4 = -2 + 1 + 1 = 0. Count Iblis (talk) 20:39, 4 October 2020 (UTC)
 * Using the sequence of multipliers 5 4 6 2 3 1 (= 105 mod 7, 104 mod 7, ..., 100 mod 7), you can extend this idea as follows: First split the number in groups of six digits written as the rows of a six-wide matrix, add the digits in each column, reducing the column sums modulo 7, multiply by the digits of 5 4 6 2 3 1 and add. Illustrated by the example of 12345678901234567890123456789:

1   2    3    4    5    6       7    8    9    0    1    2       3    4    5    6    7    8       9    0    1    2    3    4       5    6    7    8    9      --- +      25   20   25   20   25   20   or, reduced mod 7: 4   6    4    6    4    6       5×   4×   6×   2×   3×   1×      --   --   --   --   --   --      20 + 24 + 24 + 12 + 12 +  6 = 98
 * The result is divisible by 7, and so is the large number. In computing the column sums, you can of course reduce modulo 7 wherever possible, and likewise for the subsequent products and sum of products. In fact, you can already start by reducing the digits of the original number and work with 12345601201234560120123456012. If you do this, the computation is more like

1  2   3   4   5   6      0   1   2   0   1   2      3   4   5   6   0   1      2   0   1   2   3   4      5   6   0   1   2      - +      4   6   4   6   4   6      5×  4×  6×  2×  3×  1×      -   -   -   -   -   -      6 + 3 + 3 + 5 + 5 + 6 = 0
 * --Lambiam 23:13, 4 October 2020 (UTC)