Post Reply 
(50g) Integer Cube Root of an Integer
09-02-2017, 03:34 PM
Post: #1
(50g) Integer Cube Root of an Integer
For positive integer input N the programme returns the integer cube root, ie greatest integer cubed less than or equal to N.

For a random 1000 digit number

33723332557553775353525757337573537755533522772333232727225373253275725533335725​27325352752552573533222555227325357735332722375322535733533357722577325522733537​22235277532535355573272752525725227232537255772272757257527237257753332727532572​73327232573752273222237775335227233255273532577535572353227753773757222523352237​22525757355532355535723335557752773733555333732222737255732752335355532352737727​25275753355322773722522255535357537273523327777757235335733357535377323227722775​72252537733375735527537325777753357533273727575335727257327253772727233237537522​23733772357772257737732225553352323372277333273325325352557275755222353722537332​52737773327332777253377752353222323577223275257722273575357223737723575273533225​35777235737222727575772757573223575375222233277233752352773775273227357573557753​72275225532532322223772373575352252555552237577775733733523277325773755253527377​25532772333735733533753327773275227327573532275372557727335525352752377255353752​7735327732557323757327355353375255332733

the programme returns the integer cube root

14996048226776396981365120549516562555070959721242805493773661164963544888188015​56346435842736638915543782177873566529474838650069733763644482058793228038399075​85820587978412754592271325754859922095805411972846649767779396263186073689402512​30957274613534313832689378142569694744490574471694589142990940757353632225827412​71212646504465

in 70s.

Code:
::
  CK1&Dispatch
  # FF
  ::
    Z2_
    OVER
    FPTR2 ^Z>ZH
    FPTR2 ^ZBits
    BINT3
    #/
    ROTROT2DROP
    #1+
    FPTR2 ^PPow#
    BEGIN
    DUP
    BINT3
    FPTR2 ^PPow#
    DUP
    4PICK
    DUP
    FPTR2 ^RADDext
    FPTR2 ^RADDext
    3PICK
    FPTR2 ^RMULText
    SWAPDUP
    FPTR2 ^RADDext
    4PICK
    FPTR2 ^RADDext
    FPTR2 ^ZDIVext
    DROP
    DUPUNROT
    Z>
    NOT_UNTIL
    SWAPDROP
  ;
;
SIZE 127.5

CKSUM # 27E5h
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(50g) Integer Cube Root of an Integer - Gerald H - 09-02-2017 03:34 PM



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