Permuted multiples: Difference between revisions

J draft
(Added Quackery.)
(J draft)
Line 436:
6 x n = 857142
</pre>
 
=={{header|J}}==
Because 1*n and 6*n have the same number of digits, and because 2*6 is 12, we know that the first digit of n must be 1. And, because 1*y is different for any y in 1 2 3 4 5 and 6, we know that n must contain at least 6 different digits. So the smallest n must be 123456. And, as mentioned on the talk page, n must be divisible by 3.
 
In other words:
<syntaxhighlight lang=J> D*/(3+])^:(D {{1<#~./:"1~10#.inv y*m}})^:_(10#.D=:1+i.6)
142857 285714 428571 571428 714285 857142</syntaxhighlight>
 
Here, we start with <code>123456</code>, and then add <code>3</code> to it until the digits appearing in its multiples by <code>D</code>, when sorted, are all the same. (<code>D</code> is <code>1 2 3 4 5 6</code>.)
 
It's worth noting here that
<syntaxhighlight lang=J> <.1e6%7
142857</syntaxhighlight>
 
=={{header|Java}}==
6,962

edits