Anonymous user
Proper divisors: Difference between revisions
→{{header|Mathematica}} / {{header|Wolfram Language}}: The solution here was technically correct but not formatted properly. I have cleaned it up.
(→{{header|Mathematica}} / {{header|Wolfram Language}}: The solution here was technically correct but not formatted properly. I have cleaned it up.) |
|||
Line 256:
=={{header|Mathematica}} / {{header|Wolfram Language}}==
A Function that yields the proper divisors of an integer n:
Proper divisors of n from 1 to 10▼
<lang Mathematica>
▲Proper divisors of n from 1 to 10:
<lang Mathematica>Grid@Table[{n, ProperDivisors[n]}, {n, 1, 10}]</lang>
{{out}}
<pre>1 {}
Line 270 ⟶ 273:
9 {1,3}
10 {1,2,5}</pre>
The number with the most divisors between 1 and 20,000:
<lang Mathematica>Fold[
Last[SortBy[{#1, {#2, Length@ProperDivisors[#2]}}, Last]] &,
{0, 0},
Range[20000]]</lang>
{{out}}
<pre>
=={{header|Perl}}==
|