(15C) Find narcissistic / Armstrong numbers
|
02-28-2024, 04:15 PM
(This post was last modified: 03-01-2024 05:26 PM by jonakeys.)
Post: #1
|
|||
|
|||
(15C) Find narcissistic / Armstrong numbers
Hi everyone,
For a couple of weeks I've added a HP-15C CE to my calculator collection. As I like to program as a hobby, I found a nice challenge in the archive: "Short & Sweet Math Challenges for HP fans #3" Posted by Ex-PPC member on 9 June 2002, 12:43 a.m. The goal is to find Narcissistic or Armstrong numbers, for example: 1^3+5^3+3^3=153 Finding the 4 numbers (and finishing the program) for 3 digits takes around 34 seconds. How to use: Enter an integer (N) and press f LBL A to start the search. When a valid number is found, it is added to matrix A. The display shows 0.0000 when finished. Labels A: Start of program B: Fill storage registers (x^N) C: Calculate value of number D: Iterate over digits E: End Storage registers R1-R9: x^N R.0: N digits R.1: Loop from R.2: Loop to R.3: Sum number R.4: Working number Matrix A: Result numbers I've posted the code also on Github https://github.com/jonakeys/HP-15C I'm sure it can be faster/more efficient, so if you see room for improvement, feel free to comment so I can learn! Code:
edit: Add instructions of how to use / Jonathan HP 15C CE, HP 35S, HP Prime G2, Casio Graph 90+E, TI Nspire CX, TI 83, TI 84+, TI 84+ CE |
|||
02-28-2024, 11:43 PM
Post: #2
|
|||
|
|||
RE: (15C) Find narcissistic / Armstrong numbers
.
Hi, jonakeys, Welcome to the MoHPC forum ! I am the one who posted that S&SMC #3 so thank you for your interest in my production of some 22 years ago. If you'd like to see many more of my challenges (and in particular many HP-15C mini-challenges,) you can find them all in the HP Calculator Challenges Section at my site. Quote:I'm sure it can be faster/more efficient, so if you see room for improvement, feel free to comment so I can learn! The thread for my S&SMC #3 contains tons of solutions and comments on techniques to optimize the search, so you can try those ideas, collected in this 20-page PDF document. One of these days I might post an UBASIC program I wrote at the time which can find all such numbers up to 39 digits long in a very few hours on pretty ancient hardware. Again, welcome and best regards. V. All My Articles & other Materials here: Valentin Albillo's HP Collection |
|||
02-29-2024, 04:43 PM
Post: #3
|
|||
|
|||
RE: (15C) Find narcissistic / Armstrong numbers
Thanks for your kind words! And it's great that you are still around after these years and responded. I really like challenges and exercises so I'll definitely going to try more of them. Thanks for the links, I've taken a quick look and that seems promising. A lot of gathered information to dive in to.
And I'll keep my eyes open for more programs that may appear. What I like about the calculators is that even though it's more cumbersome and restricted than using a PC and programming languages, they're very capable. And limitations call for for creative solutions and thinking. / Jonathan HP 15C CE, HP 35S, HP Prime G2, Casio Graph 90+E, TI Nspire CX, TI 83, TI 84+, TI 84+ CE |
|||
03-01-2024, 07:20 AM
(This post was last modified: 03-01-2024 01:08 PM by jonakeys.)
Post: #4
|
|||
|
|||
RE: (15C) Find narcissistic / Armstrong numbers
By the way; the time it takes in seconds to calculate the answers on the HP-15C CE let's describe itself by the formula x^1.07x pretty accurately. At least for the first 5 numbers.
/ Jonathan HP 15C CE, HP 35S, HP Prime G2, Casio Graph 90+E, TI Nspire CX, TI 83, TI 84+, TI 84+ CE |
|||
03-01-2024, 03:29 PM
Post: #5
|
|||
|
|||
RE: (15C) Find narcissistic / Armstrong numbers
Question: Is step 47 supposed to be GTO C or GTO .9?
Also, I get all zeros in Matrix A. |
|||
03-01-2024, 05:31 PM
Post: #6
|
|||
|
|||
RE: (15C) Find narcissistic / Armstrong numbers
(03-01-2024 03:29 PM)Eddie W. Shore Wrote: Question: Is step 47 supposed to be GTO C or GTO .9? Thanks for noticing! You're right, step 47 is supposed to be "GTO .9". The keystroke was right, the key code wasn't. I've checked all steps with the program running on my device and all strokes+codes are correct now. Also be aware that line 73 has a 'u' in front so you have to press "f USER" before entering that line. After running the result must be in Matrix A. The program sets itself to location 1,1. When using "f USER" (42,45) you can press RCL (45) and the A-key (11) to show the number and move to the next one. Hopefully it will work this way! / Jonathan HP 15C CE, HP 35S, HP Prime G2, Casio Graph 90+E, TI Nspire CX, TI 83, TI 84+, TI 84+ CE |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)