Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Happy-numbers/PowerShell/happy-numbers-1.psh
Normal file
20
Task/Happy-numbers/PowerShell/happy-numbers-1.psh
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
function happy([int] $n) {
|
||||
$a=@()
|
||||
for($i=2;$a.count -lt $n;$i++) {
|
||||
$sum=$i
|
||||
$hist=@{}
|
||||
while( $hist[$sum] -eq $null ) {
|
||||
if($sum -eq 1) {
|
||||
$a+=$i
|
||||
}
|
||||
$hist[$sum]=$sum
|
||||
$sum2=0
|
||||
foreach($j in $sum.ToString().ToCharArray()) {
|
||||
$k=([int]$j)-0x30
|
||||
$sum2+=$k*$k
|
||||
}
|
||||
$sum=$sum2
|
||||
}
|
||||
}
|
||||
$a -join ','
|
||||
}
|
||||
2
Task/Happy-numbers/PowerShell/happy-numbers-2.psh
Normal file
2
Task/Happy-numbers/PowerShell/happy-numbers-2.psh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
happy(8)
|
||||
7,10,13,19,23,28,31,32
|
||||
Loading…
Add table
Add a link
Reference in a new issue