Permuted multiples: Difference between revisions

→‎{{header|AppleScript}}: Woke up realising that six permutations of the same digits requires the numbers to have at least three digits each.
(Added AppleScript.)
(→‎{{header|AppleScript}}: Woke up realising that six permutations of the same digits requires the numbers to have at least three digits each.)
Line 9:
 
=={{header|AppleScript}}==
{{trans|Phix}} — except that the 'steps' figure here is cumulative. Also, for six different numbers to have the same digits, each must have at least three digits, none of which can be 0. So the smallest possible value of n is 123. 'Steps' are the number of 'n's actually tried when n * 6 doesn't exceed the next power of 10. While no power of 10 is exactly divisible by 6, it ''is'' technically the point at which the number of digits increases, so I've pedantically adjusted the logic to reflect this. :) The number of steps between 100,000 and the final arrival at 142,857 is 14,286, which is interesting.
<lang applescript>use AppleScript version "2.3.1" -- Mac OS X 10.9 (Mavericks) or later.
use sorter : script "Insertion Sort" -- <https://www.rosettacode.org/wiki/Sorting_algorithms/Insertion_sort#AppleScript>
Line 32:
 
on task()
set {output, n, n10, steps} to {{}, 3123, 101000, 0}
repeat
if (n * 6 < n10) then
Line 68:
 
{{output}}
<lang applescript>"Nothing below 101000 (015 steps)
Nothing below 10010000 (2237 steps)
Nothing below 1000100000 (242459 steps)
Nothing below 10000 n = 142857 (24616745 steps altogether)
Nothing below 100000 (2468 steps)
n = 142857 (16754 steps altogether)
2 * n = 285714
3 * n = 428571
557

edits