一个有趣的数学难题
虽然它与编程不太相关,但我认为这可能会有一些帮助:
A zeroless pandigital number of base 10 is a number with all the distinct digits 1,2,3,4,5,6,7,8,9. For example, the first zeroless pandigital number of base 10 is 123456789. Find a zeroless pandigital number of base 10 such that the numbers up to the nth digit is divisible by n i.e. the number formed by 1st, 2nd and 3rd digit is divisible by 3, the number formed by 1 to 6 digits is divisible by 6 and so on.
我一开始就假设没有。 为“abcdefghi”并声明 a 可以是 “1-9”之间的任何数字 b 只能是偶数,e 肯定是 5 等等。
但我无法找到如何从这里出发。
任何帮助/或更好的方法将不胜感激
Although it is not very programming related but I think SO could be of some assistance:
A zeroless pandigital number of base 10 is a number with all the distinct digits 1,2,3,4,5,6,7,8,9. For example, the first zeroless pandigital number of base 10 is 123456789. Find a zeroless pandigital number of base 10 such that the numbers up to the nth digit is divisible by n i.e. the number formed by 1st, 2nd and 3rd digit is divisible by 3, the number formed by 1 to 6 digits is divisible by 6 and so on.
I started with thinking as assuming the no. to be "abcdefghi" and stating that a can be
any number between "1-9" b can be only the even ones, e is surely 5 and so on.
But I am not able to find how to go from here.
Any help/or better method will be appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
许多方法可以减少可能性的数量,或者至少减少计算所花费的时间。
b 必须是偶数。
(a + b + c) 必须能被 3 整除。d
必须是偶数,而且 (2c+d) 也必须能被 4 整除。e
必须是 5 或零,并且由于 0 不是泛数字中的一个选项,因此不包括 0,则 e 必须为 5。f
必须为偶数。 而且,(a + b + c + d + e + f) 必须能被 3 整除。因为我们已经知道 (a + b + c) 能被 3 整除,所以这告诉我们 (d + e + f) ) 必须能被 3 整除。
(a -2b -3c - d + 2e + 3f + g) 必须能被 7 整除。
h 必须是偶数,而且为了能被 8 整除,我们只需要检查 (4f+2g+ h) 是可整除的。
由于 b、d、f 和 h 必须均为偶数,因此 a、c、e、g、i 必须仅为奇数。
最后,所有不包含 0 的 9 位泛数字都可以被 9 整除。因此根本不需要对此进行任何测试!
Many ways to reduce the number of possibilities, or at least reduce the calculations expended.
b must be even.
(a + b + c) must be divisible by 3.
d must be even, but also (2c+d) must be divisible by 4.
e must be 5 or zero, and since 0 is not an option in a pandigital number that does not include 0, then e must be 5.
f must be even. But also, (a + b + c + d + e + f) must be divisible by 3. Since we already know that (a + b + c) is divisible by 3, then this tells us that (d + e + f) must be divisible by 3.
(a -2b -3c - d + 2e + 3f + g) must be divisible by 7.
h must be even, but also for divisibility by 8, we need only check that (4f+2g+h) is so divisible.
Since b, d, f, and h must all be even digits, then a,c,e,g,i must be only odd digits.
Finally, ALL 9 digit pandigital numbers that do not include 0 are divisible by 9. So no tests need be done for that at all!
两位数 cd(奇-偶)应能被 4 整除,三位数fgh(偶-奇-偶)应能被 8 整除。
因此,考虑到可能性,d必须是2或6,而h必须是4、2或6
这可能有助于减少可能性的数量。
The two-digit number cd (odd-even) should be divisible by 4 and the three digit number fgh(even-odd-even) should be divisible by 8.
Thus, considering the possibilities, d have to be 2 or 6, and h have to be 4, 2 or 6
This may help to reduce the number of possibilities.
为什么所有答案都在评论里? 我希望我发布答案不会违反某种我不知道的礼仪。
(b, d, f, h)
必须是按某种顺序排列的偶数(2, 4, 6, 8)
,e
必须是5
,因此(a, c, g, i)
必须是数字(1, 3, 7, 9)
一些订单。 一旦您进行了这些观察,就只有4!*4!=576
种可能性,因此请全部检查。Why are all the answers in the comments? I hope I'm not breaking some sort of etiquette I don't know about by posting an answer.
(b, d, f, h)
have to be the even numbers(2, 4, 6, 8)
in some order,e
must be5
, so(a, c, g, i)
have to be the numbers(1, 3, 7, 9)
in some order. Once you've made these observations, there are only4!*4!=576
possibilities, so check them all.