Perfect numbers: Difference between revisions
Content added Content deleted
(Add Spad code) |
|||
Line 89: | Line 89: | ||
=={{header|Axiom}}== |
=={{header|Axiom}}== |
||
{{trans|Mathematica}} |
{{trans|Mathematica}} |
||
Using the interpreter, |
Using the interpreter, define the function: |
||
<lang Axiom>perfect?(n:Integer):Boolean == reduce(+,divisors n) = 2*n</lang> |
<lang Axiom>perfect?(n:Integer):Boolean == reduce(+,divisors n) = 2*n</lang> |
||
Alternatively, using the Spad compiler: |
Alternatively, using the Spad compiler: |
||
Line 104: | Line 104: | ||
perfect? 128 |
perfect? 128 |
||
[i for i in 1..10000 | perfect? i]</lang> |
[i for i in 1..10000 | perfect? i]</lang> |
||
Output: |
|||
gives back: |
|||
<lang Axiom>true |
<lang Axiom>true |
||
false |
false |