March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
19
Task/Digital-root/PowerShell/digital-root.psh
Normal file
19
Task/Digital-root/PowerShell/digital-root.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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue