5 ms·
Here's a way I do it in my head: For every block of six digits "fedcba" calculate (a-d)+3(b-e)+2(c-f). The number is divisible by 7 if the sum is divisible by 7
by meiji163 5y ago
Here's a way I do it in my head:
For every block of six digits "fedcba" calculate (a-d)+3(b-e)+2(c-f). The number is divisible by 7 if the sum is divisible by 7.
Fun thing is you know any number with digits "abcabc" is divisible by 7.
- Andy_G11 5y agoIs this only for numbers where the number of digits is a multiple of 6?
- Robin_Message 5y agoLeft pad with zeros
- Traster 5y agoI'm kind of more intersted in why you know this. There's lots of weird esoteric stuff that I know that I need as part of my job, but what are you doing that requires you to know this that isn't "copy paste this number into a python notebook"? Oh and if you are copy pasting into notebook, then x %7 == 0 probably is a reasonable substitute...
- lurquer 5y agoI can’t speak for the poster, but I learned that trick (and many others) to play a game while stuck in traffic. Namely, derive the prime factorization of the license plate number in front of you before you lose sight of it. (Usually a 5 digit number in my area.) Sort of silly, but it passes the time.
- jldugger 5y agoI mean, who isn't loading their Anki decks with random mental math party tricks?
- meiji163 5y agoIt's just the fact that 1, 10, 100, 1000, ... = 1, 3, 2, -1, -3, -2, ... (repeating) mod 7
- tashi 5y agoI test numbers for divisibility by 7 in my head almost every time I do a daily KenKen puzzle. There's usually a four or five-digit number in there whose factors I don't know off the top of my head, so I'll give it a quick check for sevens just to get my bearings. But a python notebook could definitely beat me in a race.
- Someone 5y agoWe have abcabc = 1001 × abc = 7 × 11 × 13 × abc so abcabc also is divisible by 11 and 13. That also means that, to check divisibility of abcdef by 7, 11, or 13, compute |def-abc| and check whether that is divisible by 7, 11, or 13 since abcdef = abcabc + (def - abc) = defdef + 1000 × (abc-def) Similarly, since 10001 = 73 × 137, abcdabcd always is divisible by 73 and 137.