Magic numbers: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: added largest per digit count to output)
(J)
Line 383: Line 383:
Minimally pan-digital(0..9) magic numbers are: 3816547290
Minimally pan-digital(0..9) magic numbers are: 3816547290
</pre>
</pre>

=={{header|J}}==

Implementation:

<syntaxhighlight lang=J>ispdiv=: {{0= +/(# | 10 #. ])\ 10&#.inv y}}

{{
if. 0>nc<'pdivs' do.
pdivs=: {{
r=. 0,d=. 1 2 3 4 5 6 7 8 9x
while. #d do.
r=. r,d=. (#~ ispdiv"0), (10*d)+/i.10
end.
}}0
end.
}}0</syntaxhighlight>

Task:

<syntaxhighlight lang=J> #pdivs
20457
>./pdivs
3608528850368400786036725
(~.,. #/.~) #@":@> pdivs
1 10
2 45
3 150
4 375
5 750
6 1200
7 1713
8 2227
9 2492
10 2492
11 2225
12 2041
13 1575
14 1132
15 770
16 571
17 335
18 180
19 90
20 44
21 18
22 12
23 6
24 3
25 1
(#~ '123456789'&-:@(/:~)@":@>)pdivs
381654729
(#~ '0123456789'&-:@(/:~)@":@>)pdivs
3816547290</syntaxhighlight>


=={{header|jq}}==
=={{header|jq}}==
Line 474: Line 528:
3816547290
3816547290
</pre>
</pre>



=={{header|Pascal}}==
=={{header|Pascal}}==