Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Lucas-Lehmer-test/PowerShell/lucas-lehmer-test-1.psh
Normal file
28
Task/Lucas-Lehmer-test/PowerShell/lucas-lehmer-test-1.psh
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
function Get-MersennePrime ([bigint]$Maximum = 4800)
|
||||
{
|
||||
[bigint]$n = [bigint]::One
|
||||
|
||||
for ($exp = 2; $exp -lt $Maximum; $exp++)
|
||||
{
|
||||
if ($exp -eq 2)
|
||||
{
|
||||
$s = 0
|
||||
}
|
||||
else
|
||||
{
|
||||
$s = 4
|
||||
}
|
||||
|
||||
$n = ($n + 1) * 2 - 1
|
||||
|
||||
for ($i = 1; $i -le $exp - 2; $i++)
|
||||
{
|
||||
$s = ($s * $s - 2) % $n
|
||||
}
|
||||
|
||||
if ($s -eq 0)
|
||||
{
|
||||
$exp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
Get-MersennePrime | Format-Wide {"{0,4}" -f $_} -Column 4 -Force
|
||||
Loading…
Add table
Add a link
Reference in a new issue