Post Reply 
(EL-5030) Prime Factors
04-22-2022, 06:48 PM (This post was last modified: 04-22-2022 08:21 PM by C.Ret.)
Post: #5
RE: (EL-5030) Prime Factors
If we represent the Dave's nice AER program based on 3-loops and 3-conditionals by the following "inline-graphic":
   
Where the purple part is an outlaw AER syntax deliberately used for clarity by avoiding the element by element long list of A[..] affectations .

Code:
           ┌──────────────────────────────────────────────────────────────────────────​──────────────◄┐
           │ ┌────────────────────────────────────────────────────────────────◄┐                     │
           │ │          ┌─────────────────────────────◄┐                       │                     │
M:f(X)= #1 └►└►C+A[L]=>C└►X≠INT(X/C)*C =N=>[ C, X/C=>X ┘] ˽ L-1=>L ˽ L>0 =Y=>[ ┘] ˽ X>C*C =Y=>[ 8=>L ┘] ˽ DIM A[1] ˽ -X ■
#1:DIM A[12] ˽ { 6 2 6 4 2 4 2 4 2 2 1 2 }=>A[] ˽ 12=>L ˽ 0=>C



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
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 - 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: 3 Guest(s)