2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
16
Task/Happy-numbers/ZX-Spectrum-Basic/happy-numbers.zx
Normal file
16
Task/Happy-numbers/ZX-Spectrum-Basic/happy-numbers.zx
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
10 FOR i=1 TO 100
|
||||
20 GO SUB 1000
|
||||
30 IF isHappy=1 THEN PRINT i;" is a happy number"
|
||||
40 NEXT i
|
||||
50 STOP
|
||||
1000 REM Is Happy?
|
||||
1010 LET isHappy=0: LET count=0: LET num=i
|
||||
1020 IF count=50 OR isHappy=1 THEN RETURN
|
||||
1030 LET n$=STR$ (num)
|
||||
1040 LET count=count+1
|
||||
1050 LET isHappy=0
|
||||
1060 FOR j=1 TO LEN n$
|
||||
1070 LET isHappy=isHappy+VAL n$(j)^2
|
||||
1080 NEXT j
|
||||
1090 LET num=isHappy
|
||||
1100 GO TO 1020
|
||||
Loading…
Add table
Add a link
Reference in a new issue