Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Happy-numbers/AutoIt/happy-numbers-1.autoit
Normal file
22
Task/Happy-numbers/AutoIt/happy-numbers-1.autoit
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
$c = 0
|
||||
$k = 0
|
||||
While $c < 8
|
||||
$k += 1
|
||||
$n = $k
|
||||
While $n <> 1
|
||||
$s = StringSplit($n, "")
|
||||
$t = 0
|
||||
For $i = 1 To $s[0]
|
||||
$t += $s[$i] ^ 2
|
||||
Next
|
||||
$n = $t
|
||||
Switch $n
|
||||
Case 4,16,37,58,89,145,42,20
|
||||
ExitLoop
|
||||
EndSwitch
|
||||
WEnd
|
||||
If $n = 1 Then
|
||||
ConsoleWrite($k & " is Happy" & @CRLF)
|
||||
$c += 1
|
||||
EndIf
|
||||
WEnd
|
||||
24
Task/Happy-numbers/AutoIt/happy-numbers-2.autoit
Normal file
24
Task/Happy-numbers/AutoIt/happy-numbers-2.autoit
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
$c = 0
|
||||
$k = 0
|
||||
While $c < 8
|
||||
$a = ObjCreate("System.Collections.ArrayList")
|
||||
$k += 1
|
||||
$n = $k
|
||||
While $n <> 1
|
||||
If $a.Contains($n) Then
|
||||
ExitLoop
|
||||
EndIf
|
||||
$a.add($n)
|
||||
$s = StringSplit($n, "")
|
||||
$t = 0
|
||||
For $i = 1 To $s[0]
|
||||
$t += $s[$i] ^ 2
|
||||
Next
|
||||
$n = $t
|
||||
WEnd
|
||||
If $n = 1 Then
|
||||
ConsoleWrite($k & " is Happy" & @CRLF)
|
||||
$c += 1
|
||||
EndIf
|
||||
$a.Clear
|
||||
WEnd
|
||||
Loading…
Add table
Add a link
Reference in a new issue