Post Reply 
(EL-5030) Prime Factors
04-22-2022, 09:37 PM
Post: #8
RE: (EL-5030) Prime Factors
(04-22-2022 04:17 PM)Didier Lachieze Wrote:  Nice program! I've entered it on my EL-5030 but it returns 0 for any input.

Ok, I’ve found my mistake, I had entered a ◣ at the end of the subroutine, so the program just stopped there. After removing it it works correctly, I get the different factors until it returns -1. For 15 I get 3, 5 and -1.

(04-22-2022 08:07 PM)C.Ret Wrote:  On the SHARP, you may try the following to short your #1 Subroutine: I found same AER listings using multiple embedded store instructions, but I don't know if it's possible on the EL 5030 ?

Code:
#1: 12=>L ˽ DIM A[L] ˽ 6=>A[3]=>A[1] ˽ 4=>A[8]=>A[6]=>A[4] ˽ 2=>A[L]=>A[10]=>A[9]=>A[7]=>A[5]=>A[2] ˽ 1=>A[11] ˽ 0=>C

Yes it works on the EL-5030 (without the spaces).

(04-22-2022 06:48 PM)C.Ret Wrote:  Then, we may consider this close related but shorter and faster AER code using only 2-loops and 2-conditionals :

Code:
           ┌──────────────────────────────────────────────────────────────────────────​───────────────────────◄┐
           │                                  ┌───────────────────────────────────────────────────────────◄┐  │
M:f(X)= #1 └►F+10*FRAC(A[I])=>F ˽ INT(A[I])=>I└►Q=X/F ˽ F>Q =Y=>[ DIM A[1] ˽ -X ■ ] Q≠INT(Q) =N=>[ F, Q=>X ┘] ┘ 
#1:DIM A[12] ˽ { 2.2 3.1 4.2 5.2 6.4 7.2 8.4 9.2 10.4 11.6 12.2 5.6 }=>A[] ˽ I=1 ˽ F=0


Please fill free to test and correct my code, I (still) have no SHARP EAR hardware...
... but expecting one in a near future Smile

This one works also with a few changes:
- Replacing Q=X/F by X/F=>Q , I=1 by 1=>I and F=0 by 0=>F
- Initializing individually each element of A[]

For 15 I get 3 and -5
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(EL-5030) Prime Factors - Dave Britten - 04-21-2022, 03:01 PM
RE: (EL-5030) Prime Factors - Jlouis - 04-22-2022, 02:02 AM
RE: (EL-5030) Prime Factors - Dave Britten - 04-22-2022, 04:27 PM
RE: (EL-5030) Prime Factors - Didier Lachieze - 04-22-2022 09:37 PM
RE: (EL-5030) Prime Factors - C.Ret - 04-23-2022, 04:27 AM
RE: (EL-5030) Prime Factors - C.Ret - 04-22-2022, 06:48 PM
RE: (EL-5030) Prime Factors - Dave Britten - 04-22-2022, 07:02 PM
RE: (EL-5030) Prime Factors - C.Ret - 04-22-2022, 08:07 PM
RE: (EL-5030) Prime Factors - C.Ret - 04-23-2022, 05:07 PM



User(s) browsing this thread: 1 Guest(s)