Re: Short & Sweet Math Challenges #8: Squares ! « Next Oldest | Next Newest »

 ▼ Arnaud Amiel Senior Member Posts: 362 Threads: 30 Joined: Jul 2005 05-13-2005, 01:46 AM 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 calculated P=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 @ ``` ▼ Namir Posting Freak Posts: 2,247 Threads: 200 Joined: Jun 2005 05-13-2005, 03:34 AM Arnaud, All these challenges are not part of some post graduate homework you have been give (). Was just wondering! Namir (Basking in the sunny and sometimes cloudy southern France ... for a few days more) ▼ Arnaud Amiel Senior Member Posts: 362 Threads: 30 Joined: Jul 2005 05-13-2005, 04:24 AM Unfortunately, last time I was given some postgraduate work to do was about 5 years ago, what is more since then I have been basking in the British rain instead of the warm south of France ever since... Arnaud ▼ Namir Posting Freak Posts: 2,247 Threads: 200 Joined: Jun 2005 05-13-2005, 06:16 AM Arnaud, You are missing the beauty and magic of southern France. They predictewd clouds today ... well not for long. It's sunny and beautiful at noon today!! It's hard to stay inside and play with the internet and HP emulators. I am surrendering to the temptation of this nice weather. Namir

 Possibly Related Threads... Thread Author Replies Views Last Post Need help understanding math.... cyrille de Brébisson 9 1,921 12-13-2013, 02:23 AM Last Post: Didier Lachieze HP Prime - Short "learning" modules CR Haeger 1 714 11-27-2013, 02:13 PM Last Post: Jonathan Cameron I have written a short introduction to the HP Prime Michael Carey 7 1,465 11-18-2013, 08:04 PM Last Post: Michael Carey HP-65 short circuit Ignacio Sánchez 2 818 10-22-2013, 08:27 AM Last Post: Ignacio Sánchez Reig OT: a math competition site Pier Aiello 0 543 09-16-2013, 06:03 AM Last Post: Pier Aiello Simple Math Question Namir 2 751 08-09-2013, 06:13 PM Last Post: Eddie W. Shore Cool math clock Bruce Bergman 28 3,623 04-10-2013, 03:13 AM Last Post: Siegfried (Austria) FRAM71 for HP-71B, short update #3 Hans Brueggemann 15 1,985 01-20-2013, 10:22 AM Last Post: Jerry Raia Math Challenge I could not solve Meindert Kuipers 22 2,962 01-05-2013, 04:43 PM Last Post: Thomas Klemm Math Question Namir 0 477 11-06-2012, 07:43 AM Last Post: Namir

Forum Jump: