Post Reply 
Mini-challenge: MAX(factors of 2 or 5)
01-17-2018, 06:13 AM (This post was last modified: 01-17-2018 06:26 AM by Gerald H.)
Post: #5
RE: Mini-challenge: MAX(factors of 2 or 5)
User & Sys suggestions:

Code:
« 0 SWAP
  WHILE DUP 2 IDIV2
0 SAME
  REPEAT NIP SWAP 1
+ SWAP
  END DROP 0 SWAP
  WHILE DUP 5 IDIV2
0 SAME
  REPEAT NIP SWAP 1
+ SWAP
  END DROP2 MAX
»

Code:
::
  CK1&Dispatch
  # FF
  ::
    FPTR2 ^ZTrialDiv2
    BINT0
    ROT
    BEGIN
    DUP
    ZINT 5
    FPTR2 ^ZDIVext
    ZINT 0
    EQUAL
    WHILE
    ::
      SWAPDROP
      SWAP#1+SWAP
    ;
    REPEAT
    2DROP
    #MAX
    FPTR2 ^#>Z
  ;
;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Mini-challenge: MAX(factors of 2 or 5) - Gerald H - 01-17-2018 06:13 AM



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