Perfect numbers: Difference between revisions

Content deleted Content added
m Added wp ref and fixed definition - see discussion
+Icon+Unicon
Line 328:
perfect = sum == n
END</lang>
 
== Icon and Unicon ==
==={{header|Icon}}===
<lang Icon>procedure main(arglist)
limit := \arglist[1] | 100000
write("Perfect numbers from 1 to ",limit,":")
every write(isperfect(1 to limit))
write("Done.")
end
 
procedure isperfect(n) #: returns n if n is perfect
local sum,i
 
every (sum := 0) +:= (n ~= divisors(n))
if sum = n then return n
end
 
link factors</lang>
 
The {{libheader|Icon Programming Library}} [http://www.cs.arizona.edu/icon/library/src/procs/factors.icn divisors]
 
Sample Output:
<pre>Perfect numbers from 1 to 100000:
6
28
496
8128
Done.</pre>
 
==={{header|Unicon}}===
The Icon solution works in Unicon.
 
=={{header|J}}==