The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
(49G) Improved IEGCD for Integers
06-05-2015, 11:43 AM (This post was last modified: 06-15-2017 01:45 PM by Gene.)
Post: #1
(49G) Improved IEGCD for Integers
The programme is faster than the inbuilt command IEGCD but in contrast always returns a positive GCD in stack level Z.

eg For input

77
121

the programme returns

11
-3
2

Name: IZEGCD

Code:
::
  CK2&Dispatch
  # FFFF
  ::
    BINT0
    3UNROLL
    BEGIN
    ROT#1+UNROT
    DUPUNROT
    FPTR2 ^ZDIVext
    SWAP
    4UNROLLDUP
    Z0_
    EQUAL
    UNTIL
    DROP
    ZINT1_0_
    4ROLL
    ZERO_DO
    DUPUNROT
    5ROLL
    FPTR2 ^QMul
    FPTR2 ^QSub
    LOOP
    3PICK
    FPTR2 ^ZIsNeg?
    NOT?SEMI
    BINT3
    ZERO_DO
    ROT
    FPTR2 ^RNEGext
    LOOP
  ;
;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(49G) Improved IEGCD for Integers - Gerald H - 06-05-2015 11:43 AM



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