mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-17 10:11:27 +01:00
Renamed to write-pi.ps1
This commit is contained in:
parent
73a3646ab7
commit
8a33a05610
@ -1,12 +1,12 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Lists PI
|
Writes PI
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script calculates and lists the digits of the mathematical constant PI.
|
This PowerShell script calculates and writes the digits of the mathematical constant PI.
|
||||||
.PARAMETER digits
|
.PARAMETER digits
|
||||||
Specifies the number of digits to list (1000 by default)
|
Specifies the number of digits to list (1000 by default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./list-pi.ps1
|
PS> ./write-pi.ps1
|
||||||
3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342...
|
3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342...
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
@ -14,9 +14,9 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param([int]$Digits = 1000)
|
param([int]$digits = 1000)
|
||||||
|
|
||||||
function List-Pi ( $Digits ) {
|
function Write-Pi ( $digits ) {
|
||||||
$Big = [bigint[]](0..10)
|
$Big = [bigint[]](0..10)
|
||||||
|
|
||||||
$ndigits = 0
|
$ndigits = 0
|
||||||
@ -43,7 +43,7 @@ function List-Pi ( $Digits ) {
|
|||||||
$q *= $Big[10]
|
$q *= $Big[10]
|
||||||
$r = $nr
|
$r = $nr
|
||||||
|
|
||||||
while ($ndigits -lt $Digits) {
|
while ($ndigits -lt $digits) {
|
||||||
if ($Big[4] * $q + $r - $t -lt $n * $t) {
|
if ($Big[4] * $q + $r - $t -lt $n * $t) {
|
||||||
Write-Host "$n" -noNewline
|
Write-Host "$n" -noNewline
|
||||||
$ndigits++
|
$ndigits++
|
||||||
@ -62,11 +62,11 @@ function List-Pi ( $Digits ) {
|
|||||||
$r = $nr
|
$r = $nr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Write-Host "... ($Digits digits)"
|
Write-Host "... ($digits digits)"
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List-Pi $Digits
|
Write-Pi $digits
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
Loading…
Reference in New Issue
Block a user