Proper divisors: Difference between revisions
Content added Content deleted
Line 1,031: | Line 1,031: | ||
=={{header|PowerShell}}== |
=={{header|PowerShell}}== |
||
===version 1=== |
|||
<lang PowerShell> |
|||
function proper-divisor ($n) { |
|||
if($n -gt 2) { |
|||
$lim = [Math]::Floor($n/2)+1 |
|||
$proper = @(1) |
|||
for($i = 2; $i -lt $lim; $i++){ |
|||
if($n%$i -eq 0) { |
|||
$proper += @($i) |
|||
} |
|||
} |
|||
$proper |
|||
} else {@()} |
|||
} |
|||
"$(proper-divisor 100)" |
|||
"$(proper-divisor 496)" |
|||
"$(proper-divisor 2048)" |
|||
</lang> |
|||
===version 2=== |
|||
<lang PowerShell> |
<lang PowerShell> |
||
function eratosthenes ($n) { |
function eratosthenes ($n) { |