HHC 2019 will be in Reno, Nevada, Sept 21-22
|
09-28-2019, 01:26 AM
(This post was last modified: 10-11-2019 01:06 AM by Albert Chan.)
Post: #52
|
|||
|
|||
RE: HHC 2019 will be in Reno, Nevada, Sept 21-22
HP71B version, with a running sum of number less cube of its digits.
If the total is zero, we found an Armstrong number. Slight optimization on the inner loop. Instead of running from 0 to 9, do 2 to 9 If Armstrong number N last digit is 0, N+1 must also be an Armstrong number. Code: 10 DESTROY ALL @ DIM C(10) @ FOR I=1 TO 9 @ C(I)=I^3-I @ NEXT I Note: discovered a BASIC quirk FOR NEXT loops variable ends with first value that failed the loop. >FOR K=1 TO 100 STEP 7 @ NEXT K >K 106 So, above code Z loop can also do 2 to 8, and still run correctly. Update: Y loop optimized with parity test, cutting search space in half. see https://www.hpmuseum.org/forum/thread-13791.html |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 25 Guest(s)