Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,28 +0,0 @@
|
|||
function pop-count($n) {
|
||||
(([Convert]::ToString($n, 2)).toCharArray() | where {$_ -eq '1'}).count
|
||||
}
|
||||
|
||||
function isPrime ($n) {
|
||||
if ($n -eq 1) {$false}
|
||||
elseif ($n -eq 2) {$true}
|
||||
elseif ($n -eq 3) {$true}
|
||||
else{
|
||||
$m = [Math]::Floor([Math]::Sqrt($n))
|
||||
(@(2..$m | where {($_ -lt $n) -and ($n % $_ -eq 0) }).Count -eq 0)
|
||||
}
|
||||
}
|
||||
|
||||
$i = 0
|
||||
$num = 1
|
||||
$arr = while($i -lt 25) {
|
||||
if((isPrime (pop-count $num))) {
|
||||
$i++
|
||||
$num
|
||||
}
|
||||
$num++
|
||||
}
|
||||
"first 25 pernicious numbers"
|
||||
"$arr"
|
||||
""
|
||||
"pernicious numbers between 888,888,877 and 888,888,888"
|
||||
"$(888888877..888888888 | where{isprime(pop-count $_)})"
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
function Select-PerniciousNumber
|
||||
{
|
||||
[CmdletBinding()]
|
||||
[OutputType([int])]
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$true,
|
||||
ValueFromPipeline=$true,
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
Position=0)]
|
||||
$InputObject
|
||||
)
|
||||
|
||||
Begin
|
||||
{
|
||||
function Test-Prime ([int]$n)
|
||||
{
|
||||
$n = [Math]::Abs($n)
|
||||
|
||||
if ($n -eq 0 -or $n -eq 1) {return $false}
|
||||
|
||||
for ($m = 2; $m -le [Math]::Sqrt($n); $m++)
|
||||
{
|
||||
if (($n % $m) -eq 0) {return $false}
|
||||
}
|
||||
|
||||
return $true
|
||||
}
|
||||
|
||||
[scriptblock]$popCount = {(([Convert]::ToString($this, 2)).ToCharArray() | Where-Object {$_ -eq '1'}).Count}
|
||||
}
|
||||
Process
|
||||
{
|
||||
foreach ($object in $InputObject)
|
||||
{
|
||||
$object | Add-Member -MemberType ScriptProperty -Name PopCount -Value $popCount -Force -PassThru | ForEach-Object {
|
||||
if (Test-Prime $_.PopCount)
|
||||
{
|
||||
$_
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
$start, $end = 0, 999999
|
||||
$range1 = $start..$end | Select-PerniciousNumber | Select-Object -First 25
|
||||
|
||||
"First {0} pernicious numbers:`n{1}`n" -f $range1.Count, ($range1 -join ", ")
|
||||
|
||||
$start, $end = 888888877, 888888888
|
||||
$range2 = $start..$end | Select-PerniciousNumber
|
||||
|
||||
"Pernicious numbers between {0} and {1}:`n{2}`n" -f $start, $end, ($range2 -join ", ")
|
||||
Loading…
Add table
Add a link
Reference in a new issue