HP Forums
(71B) Expanding the Binomial (ax+b)^n - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (71B) Expanding the Binomial (ax+b)^n (/thread-6463.html)



(71B) Expanding the Binomial (ax+b)^n - Eddie W. Shore - 06-27-2016 03:29 AM

BINOMEXP gives the coefficients of the expansion of (ax+b)^n.
Code:

Program BINOMEXP (about 189 bytes)

10 DESTROY A,B,N,L,I,C
12 OPTION BASE 0
14 DISP ‘exapand(Ax+B)^N’ @ WAIT 1
16 INPUT “A,B,N”;A,B,N
18 DIM L(N)
20 FOR I=0 TO N
22 C=FACT(N)/(FACT(I)*FACT(N-I))  \\ FACT is the factorial function
24 L(I)=C*A^(N-I)*B^I
26 DISP “L(“; I; ”):”; L(I); “x^”; N-I  @ PAUSE
28 NEXT I
40 DISP “DONE, CHECK L.”