Abundant, deficient and perfect number classifications: Difference between revisions
Abundant, deficient and perfect number classifications (view source)
Revision as of 16:03, 5 November 2023
, 6 months ago→{{header|Wren}}: Minor tidy & corrected alternative version.
Not a robot (talk | contribs) (add SETL) |
(→{{header|Wren}}: Minor tidy & corrected alternative version.) |
||
Line 5,692:
===Using modulo/division===
{{libheader|Wren-math}}
<syntaxhighlight lang="
var d = 0
Line 5,722:
{{Trans|Lua|Summing the factors using a table}}
<syntaxhighlight lang="
var abundantCount = 0
var deficientCount = 0
var perfectCount = 0
var pds
pds.add(
pds.add(
for (
pds.add(
}
for (
var j = i + i
while
pds[
j = j + i
}
}
for (
var pdSum = pds[
if
deficientCount = deficientCount + 1
} else if (
perfectCount
} else { // pdSum > n
abundantCount
}
}
System.print(
System.print(
System.print(
{{out}}
<pre>
Abundant :
Deficient:
Perfect : 4
</pre>
|