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

@ -0,0 +1,25 @@
function Test-Kaprekar ([int]$Number)
{
if ($Number -eq 1)
{
return $true
}
[int64]$a = $Number * $Number
[int64]$b = 10
while ($b -lt $a)
{
[int64]$remainder = $a % $b
[int64]$quotient = ($a - $remainder) / $b
if ($remainder -gt 0 -and $remainder + $quotient -eq $Number)
{
return $true
}
$b *= 10
}
return $false
}

View file

@ -0,0 +1,5 @@
"Kaprekar numbers less than 10,000:"
1..10000 | ForEach-Object {if (Test-Kaprekar -Number $_) {"{0,6}" -f $_}} | Format-Wide {$_} -Column 17 -Force
"Kaprekar numbers less than 1,000,000:"
1..1000000 | ForEach-Object {if (Test-Kaprekar -Number $_) {"{0,6}" -f $_}} | Format-Wide {$_} -Column 18 -Force