Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
19
Task/Digital-root/PowerShell/digital-root-1.psh
Normal file
19
Task/Digital-root/PowerShell/digital-root-1.psh
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
function Get-DigitalRoot ($n)
|
||||
{
|
||||
function Get-Digitalsum ($n)
|
||||
{
|
||||
if ($n -lt 10) {$n}
|
||||
else {
|
||||
($n % 10) + (Get-DigitalSum ([math]::Floor($n / 10)))
|
||||
}
|
||||
}
|
||||
|
||||
$ap = 0
|
||||
do {$n = Get-DigitalSum $n; $ap++}
|
||||
until ($n -lt 10)
|
||||
$DigitalRoot = [pscustomobject]@{
|
||||
'Sum' = $n
|
||||
'Additive Persistence' = $ap
|
||||
}
|
||||
$DigitalRoot
|
||||
}
|
||||
9
Task/Digital-root/PowerShell/digital-root-2.psh
Normal file
9
Task/Digital-root/PowerShell/digital-root-2.psh
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
function Get-DigitalRoot {
|
||||
param($n)
|
||||
$ap = 0
|
||||
do {$n = Invoke-Expression ("0"+([string]$n -split "" -join "+")+"0"); $ap++} while ($n -ge 10)
|
||||
[PSCustomObject]@{
|
||||
DigitalRoot = $n
|
||||
AdditivePersistence = $ap
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue