2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,7 +1,14 @@
function Get-DigitalSum ($n)
function Get-DigitalSum ([string] $number, $base = 10)
{
if ($n -lt 10) {$n}
else {
($n % 10) + (Get-DigitalSum ([math]::Floor($n / 10)))
if ($number.ToCharArray().Length -le 1) { [Convert]::ToInt32($number, $base) }
else
{
$result = 0
foreach ($character in $number.ToCharArray())
{
$digit = [Convert]::ToInt32(([string]$character), $base)
$result += $digit
}
return $result
}
}