Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,17 +0,0 @@
|
|||
function proper-divisor ($n) {
|
||||
if($n -ge 2) {
|
||||
$lim = [Math]::Floor([Math]::Sqrt($n))
|
||||
$less, $greater = @(1), @()
|
||||
for($i = 2; $i -lt $lim; $i++){
|
||||
if($n%$i -eq 0) {
|
||||
$less += @($i)
|
||||
$greater = @($n/$i) + $greater
|
||||
}
|
||||
}
|
||||
if(($lim -ne 1) -and ($n%$lim -eq 0)) {$less += @($lim)}
|
||||
$($less + $greater)
|
||||
} else {@()}
|
||||
}
|
||||
"$(proper-divisor 100)"
|
||||
"$(proper-divisor 496)"
|
||||
"$(proper-divisor 2048)"
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
function proper-divisor ($n) {
|
||||
if($n -ge 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)"
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
function eratosthenes ($n) {
|
||||
if($n -gt 1){
|
||||
$prime = @(0..$n| foreach{$true})
|
||||
$m = [Math]::Floor([Math]::Sqrt($n))
|
||||
function multiple($i) {
|
||||
for($j = $i*$i; $j -le $n; $j += $i) {
|
||||
$prime[$j] = $false
|
||||
}
|
||||
}
|
||||
multiple 2
|
||||
for($i = 3; $i -le $m; $i += 2) {
|
||||
if($prime[$i]) {multiple $i}
|
||||
}
|
||||
2
|
||||
for($i = 3; $i -le $n; $i += 2) {
|
||||
if($prime[$i]) {$i}
|
||||
}
|
||||
|
||||
} else {
|
||||
Write-Error "$n is not greater than 1"
|
||||
}
|
||||
}
|
||||
function prime-decomposition ($n) {
|
||||
$array = eratosthenes $n
|
||||
$prime = @()
|
||||
foreach($p in $array) {
|
||||
while($n%$p -eq 0) {
|
||||
$n /= $p
|
||||
$prime += @($p)
|
||||
}
|
||||
}
|
||||
$prime
|
||||
}
|
||||
function proper-divisor ($n) {
|
||||
if($n -ge 2) {
|
||||
$array = prime-decomposition $n
|
||||
$lim = $array.Count
|
||||
function state($res, $i){
|
||||
if($i -lt $lim) {
|
||||
state ($res) ($i + 1)
|
||||
state ($res*$array[$i]) ($i + 1)
|
||||
} elseif($res -lt $n) {$res}
|
||||
}
|
||||
state 1 0 | sort -Unique
|
||||
} else {@()}
|
||||
}
|
||||
"$(proper-divisor 100)"
|
||||
"$(proper-divisor 496)"
|
||||
"$(proper-divisor 2048)"
|
||||
Loading…
Add table
Add a link
Reference in a new issue