This is a follow up to an archived message.
Ihad posted a Saturn Assembly solution to this challenge but felt it could do with some tiyding up. So I did and gained a few seconds. Then I realised that most of the time was spent squaring the numbers. Knowing that the sum of odd numbers is the list of square numbers, I could change the squaring into a mere couple of additions. This code now runs much faster.
It takes 5.3s on a 49g+ and 13s on a 48GX. I am not talking about emulated speed here but real speed. I still need to port it to the 28S. The 71 has a Saturn but I don't have one and don't know what is its support for assembly...
I can send you the compiled program if you email me.
Arnaud
SAVE SETDEC
LA 1111088889000
C=0.M LC 66665000 B=C.M
LC 33333 RSTK=C*NextNumber
C=RSTK C+1.A
SKIPNC { P=0 SETHEX LOADRPL }
RSTK=C
B+1.M B+1.M A+B.M C=A.M %This is were the square is calculatedP=5 A=0.XS B=0.XS D=0.XS
*TestNumber
P+1 GOC GoodNumber
CSR.W
?C=0.XS GOYES NextNumber
?A#0.XS { A=C.XS GOTO TestNumber }
?A=C.XS GOYES TestNumber
?B#0.XS { B=C.XS GOTO TestNumber }
?B=C.XS GOYES TestNumber
?D#0.XS { D=C.XS GOTO TestNumber }
?D=C.XS GOYES TestNumber
GOTO NextNumber*GoodNumber
R1=A.M
C=B.M R2=C.M
ASL.M ASL.M
LA 009
A=0.S
GOSBVL =PUSH%
SAVE
SETDEC
A=R1.M
C=R2.M B=C.M
GOTO NextNumber
@