Factor-perfect numbers: Difference between revisions

Content added Content deleted
mNo edit summary
(→‎{{header|J}}: include first seven factor-perfect numbers)
Line 51: Line 51:
<syntaxhighlight lang=J>factors=: {{/:~*/@>,{(^ i.)&.>/0 1+__ q:y}}
<syntaxhighlight lang=J>factors=: {{/:~*/@>,{(^ i.)&.>/0 1+__ q:y}}
fp1=: {{ {{y#~0*/ .=~2|/\&>y}} y<@#"1~1,.~1,.#:i.2^_2+#y }}@factors
fp1=: {{ {{y#~0*/ .=~2|/\&>y}} y<@#"1~1,.~1,.#:i.2^_2+#y }}@factors
fp2=: 2 %~/\&.> fp1</syntaxhighlight>
fp2=: 2 %~/\&.> fp1
Fi=: i.0
F=: {{
if. y>:#Fi do. Fi=: Fi{.~1+y end.
if. (1<y)*0=y{Fi do. Fi=: Fi y}~ 1++/F y%}.factors y end.
y{Fi
}}"0</syntaxhighlight>
Task examples (formed into 8 columns for easy viewing):
Task examples (formed into 8 columns for easy viewing):
<syntaxhighlight lang=J> _8,\fp1 48
<syntaxhighlight lang=J> _8,\fp1 48
Line 80: Line 86:
├───────┼───────┼───────┼─────────┼─────────┼───────┼─────────┼─────────┤
├───────┼───────┼───────┼─────────┼─────────┼───────┼─────────┼─────────┤
│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│
│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>
└───────┴───────┴───────┴─────────┴─────────┴───────┴─────────┴─────────┘
0 1,(#~ (=F)) 2+i.30000

0 1 48 1280 2496 28672 29808
</syntaxhighlight>


=={{header|Julia}}==
=={{header|Julia}}==