Post Reply 
(50g) Sum of Divisors to an Integer Power
04-16-2018, 07:24 AM
Post: #1
(50g) Sum of Divisors to an Integer Power
For stack input

Z an Integer
P an integer Real

the programme returns the sum of

Divisor^P

NB For P=0. the programme returns the number of divisors.

Size: 202.5

CkSum: # 2199h

Code:
::
  CK2&Dispatch
  # FF1
  ::
    %ABSCOERCE
    ::
      DUP#0=csedrp
      {
        ROTDROPSWAP
        %1+
        FPTR2 ^R>Z
        FPTR2 ^RMULText
      }
      {
        3PICK
        ROT
        COERCE
        #1+
      }
      OVER
      >TCOMP
      {
        #*
        FPTR2 ^PPow#
        ZINT 1
        FPTR2 ^QSub
        ROT
      }
      &COMP
      SWAP
      >TCOMP
      {
        FPTR2 ^PPow#
        ZINT 1
        FPTR2 ^QSub
        FPTR2 ^ZQUOText
        FPTR2 ^QMul
      }
      &COMP
    ;
    1LAMBIND
    ::
      FPTR2 ^ZAbs
      FPTR2 ^DupQIsZero?
      caseSIZEERR
      FPTR2 ^DupZIsOne?
      ?SEMI
      FPTR2 ^MZSQFF
      #2/
      ZINT 1
      SWAP
      ZERO_DO
      1GETLAM
      COMPEVAL
      LOOP
    ;
    ABND
  ;
;
Find all posts by this user
Quote this message in a reply
Post Reply 




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