# TITLE: Sum a Range of Kth Powers of Integers N # ORIGINAL AUTHOR: Roy Maclean 3rd February 2001 # MODIFICATION AUTHOR: BazzaB 1st December 2003 # EMAIL: barries_ecdl@hotmail.com # MAKE: Casio # MODEL: CFX-9850G or similar # NOTES: Follow the on-screen prompts. # Makes use of Roy's 'SUMKPOW' program as a subroutine. # E.g. If you want 4^16 + 5^16 + 6^16 + 7^16 + 8^16 # then enter 16 when asked for the power K, and then # enter 4 when asked for 'L', and 8 when asked for 'U'. # The result should be 3.176859 times 10 to the power 14. # # Needs Subroutine "S-POWR", shown at the end of the main listing # adapted from Roy's original. # KEYS: # * multiply by below [ DEL ] # -> assignment above [ AC/ON ] # => if-then shift vars f3 f3 # <> not equal shift vars f6 f3 f2 # ^2 squared use [ x squared ] key # { left brace shift [ * ] # [ left bracket shift [ + ] # ] right bracket shift [ - ] # \sum( summation optn f4 f6 f3 # nCr combinations optn f6 f3 f3 ( fat letter C ) #__________________________________________________ @@ Program "SUMPOWR" Lbl A Norm:ClrList:0->A~K Do:ClrText "ENTER THE POWER 'K'"?->A LpWhile Frac A+(A<1 Do:ClrText "ENTER 'L', THE":"LOWER LIMIT OF N"?->B LpWhile Frac B+(B<1 Alog B>99.974->C If Not C:Then Do:ClrText "ENTER 'U', THE":"UPPER LIMIT OF N"?->D LpWhile Frac D+(D99.974->E If Not E Then If B=1 Then D->F Prog "S-POWR":G->H IfEnd If B>1 Then Do:Isz I I=1=>D->F:I=2=>B-1->F Prog "S-POWR" I=1=>G->J:I=2=>G->K LpWhile I<3 J-K->H IfEnd ' RESULT ClrText:Locate 1,1,B log B+2->I:Locate I,1,"^":Locate I+1,1,A Locate 5,2,"+....+":Locate 1,3,D log D+2->I:Locate I,3,"^":Locate I+1,3,A Locate 1,5,"=":Locate 3,5,H IfEnd IfEnd If E+C:Then ClrText ' OVERFLOW "THAT WILL PROBABLY":"CAUSE A 'MATH ERROR'" " " ; 1 spc "EITHER 'K' OR 'L'":E=>Locate 16,4,"U'" "IS TOO BIG. TRY AGAIN" IfEnd Locate 6,7,"PRESS 'EXE'":While Getkey<>31:WhileEnd Goto A #_____________________________________________ # Subroutine for Program "SUMPOWR" @@ Program "S-POWR" If F>.696A^2+1.748A-25.711 Then Seq(1,X,1,A,1 List Ans->List 1 For 1->L To A For 1->M To L-2 (L-M)List Ans[M]+(M+1)List Ans[M+1->List 1[M+1 Next List 1 Next \sum(List Ans[X]((F+X)nCr(A+1,X,1+(FG Return IfEnd \sum(X^A,X,1,F,1->G #_____________________________________________