Perfect numbers: Difference between revisions

Content deleted Content added
Hout (talk | contribs)
→‎{{header|Python}}: Updated older functional version to work with Python 3 and generate output
Line 945: Line 945:
</pre>
</pre>
=={{header|Elena}}==
=={{header|Elena}}==
ELENA 3.4:
ELENA 4.x:
<lang elena>import system'routines.
<lang elena>import system'routines;
import system'math.
import system'math;
import extensions.
import extensions;
extension extension
extension extension
{
{
isPerfect
isPerfect()
= 1 till:self repeat(:n)( (self mod:n == 0) iif(n,0) ); summarize(Integer new) == self.
= new Range(1, self - 1).selectBy:(n => (self.mod:n == 0).iif(n,0) ).summarize(new Integer()) == self;
}
}
public program
public program()
{
[
1 till:10000 do(:n)
for(int n := 1, n < 10000, n += 1)
[
{
if(n isPerfect)
if(n.isPerfect())
[ console printLine(n," is perfect") ]
{ console.printLine(n," is perfect") }
].
};
console readChar
console.readChar()
]</lang>
}</lang>
{{out}}
{{out}}
<pre>
<pre>