# TITLE: Summing Kth Powers # AUTHOR: Roy F.A. Maclean # EMAIL: rfamgm at gmail # WEB: http://www.spiderpixel.co.uk/caspro # DATE: 3rd February 2001 # MAKE: CASIO # MODEL: 9850G # NOTES: # To sum 1+2+3+4 + ... to N you could use the # formula N(N+1)/2 # # To sum 1^2 + 2^2 +3^2 + ... +N^2 you could use a formula # or the built in sum function on optn f4 f6 f3 # # To sum 1^k + 2^k + ... N^k you could use the built in # sum function but it would be slow for large N, # # so here is a program which will find the sum of the # first n terms of the kth powers. For small N the program # uses the built in sum, but for large n it uses # eulerian numbers and binomial coefficients to speed things up. # # For more information see the book "Mathematical Recreations" # by Hilton, Holton and Pederson, published by Springer. # # nCr is on the optn f6 f3 f3 menu # \sum is on the optn f4 f6 f3 menu # 0 is the number zero # _ (underscore) represents the triangle display symbol on the pgrm menu # <> is the not-equal-to symbol @@ Program "SUMKPOW" 0->A 1->B Lbl 0 "K"?->J "N"?->N If J=A And B=0 Then Goto 1 IfEnd J->A If N<.696A^2+1.748A-25.711 Then Goto 2 IfEnd 0->B Seq(1,X,1,A,1 List Ans->List 1 For 1->K To A For 1->I to K-2 (K-I)List Ans[I]+(I+1)List Ans[I+1->List 1[I+1 Next List 1 Next Lbl 1 \sum(List Ans[X]((N+X) nCr (A+1,X,1+(NB \sum(X^A,X,1,N,1_ Goto 0