Jump to content

Factor-perfect numbers: Difference between revisions

J draft
m (→‎{{header|Phix}}: replaced my beloved g() with the even faster cached erdosFactorCount().)
(J draft)
Line 46:
[[wp:Enumerative_combinatorics|Wikipedia: Enumerative Combinatorics]]
<br /><br /><br />
 
=={{header|J}}==
Implementation:
<syntaxhighlight lang=J>factors=: {{/:~*/@>,{(^ i.)&.>/0 1+__ q:y}}
fp1=: {{ {{y#~0*/ .=~2|/\&>y}} y<@#"1~1,.~1,.#:i.2^_2+#y }}@factors
fp2=: 2 %~/\&.> fp1</syntaxhighlight>
Task examples (formed into 8 columns for easy viewing):
<syntaxhighlight lang=J> _8,\fp1 48
┌────────────┬───────────┬───────────┬──────────────┬──────────────┬───────────┬─────────────┬──────────────┐
│1 48 │1 24 48 │1 16 48 │1 12 48 │1 12 24 48 │1 8 48 │1 8 24 48 │1 8 16 48 │
├────────────┼───────────┼───────────┼──────────────┼──────────────┼───────────┼─────────────┼──────────────┤
│1 6 48 │1 6 24 48 │1 6 12 48 │1 6 12 24 48 │1 4 48 │1 4 24 48 │1 4 16 48 │1 4 12 48 │
├────────────┼───────────┼───────────┼──────────────┼──────────────┼───────────┼─────────────┼──────────────┤
│1 4 12 24 48│1 4 8 48 │1 4 8 24 48│1 4 8 16 48 │1 3 48 │1 3 24 48 │1 3 12 48 │1 3 12 24 48 │
├────────────┼───────────┼───────────┼──────────────┼──────────────┼───────────┼─────────────┼──────────────┤
│1 3 6 48 │1 3 6 24 48│1 3 6 12 48│1 3 6 12 24 48│1 2 48 │1 2 24 48 │1 2 16 48 │1 2 12 48 │
├────────────┼───────────┼───────────┼──────────────┼──────────────┼───────────┼─────────────┼──────────────┤
│1 2 12 24 48│1 2 8 48 │1 2 8 24 48│1 2 8 16 48 │1 2 6 48 │1 2 6 24 48│1 2 6 12 48 │1 2 6 12 24 48│
├────────────┼───────────┼───────────┼──────────────┼──────────────┼───────────┼─────────────┼──────────────┤
│1 2 4 48 │1 2 4 24 48│1 2 4 16 48│1 2 4 12 48 │1 2 4 12 24 48│1 2 4 8 48 │1 2 4 8 24 48│1 2 4 8 16 48 │
└────────────┴───────────┴───────────┴──────────────┴──────────────┴───────────┴─────────────┴──────────────┘
_8,\fp2 48
┌───────┬───────┬───────┬─────────┬─────────┬───────┬─────────┬─────────┐
│48 │24 2 │16 3 │12 4 │12 2 2 │8 6 │8 3 2 │8 2 3 │
├───────┼───────┼───────┼─────────┼─────────┼───────┼─────────┼─────────┤
│6 8 │6 4 2 │6 2 4 │6 2 2 2 │4 12 │4 6 2 │4 4 3 │4 3 4 │
├───────┼───────┼───────┼─────────┼─────────┼───────┼─────────┼─────────┤
│4 3 2 2│4 2 6 │4 2 3 2│4 2 2 3 │3 16 │3 8 2 │3 4 4 │3 4 2 2 │
├───────┼───────┼───────┼─────────┼─────────┼───────┼─────────┼─────────┤
│3 2 8 │3 2 4 2│3 2 2 4│3 2 2 2 2│2 24 │2 12 2 │2 8 3 │2 6 4 │
├───────┼───────┼───────┼─────────┼─────────┼───────┼─────────┼─────────┤
│2 6 2 2│2 4 6 │2 4 3 2│2 4 2 3 │2 3 8 │2 3 4 2│2 3 2 4 │2 3 2 2 2│
├───────┼───────┼───────┼─────────┼─────────┼───────┼─────────┼─────────┤
│2 2 12 │2 2 6 2│2 2 4 3│2 2 3 4 │2 2 3 2 2│2 2 2 6│2 2 2 3 2│2 2 2 2 3│
└───────┴───────┴───────┴─────────┴─────────┴───────┴─────────┴─────────┘</syntaxhighlight>
 
 
=={{header|Julia}}==
6,962

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.