How to resolve the algorithm Evaluate binomial coefficients step by step in the Commodore BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Evaluate binomial coefficients step by step in the Commodore BASIC programming language

Table of Contents

Problem Statement

This programming task, is to calculate ANY binomial coefficient. However, it has to be able to output

(

5 3

)

{\displaystyle {\binom {5}{3}}}

,   which is   10. This formula is recommended:

See Also:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Evaluate binomial coefficients step by step in the Commodore BASIC programming language

Source code in the commodore programming language

10 REM BINOMIAL COEFFICIENTS
20 REM COMMODORE BASIC 2.0
30 REM 2021-08-24
40 REM BY ALVALONGO
100 Z=0:U=1
110 FOR N=U TO 10
120 PRINT N;
130 FOR K=Z TO N
140 GOSUB 900
150 PRINT C;
160 NEXT K
170 PRINT
180 NEXT N
190 END
900 REM BINOMIAL COEFFICIENT
910 IF KN THEN C=Z:RETURN
920 IF K=Z OR K=N THEN C=U:RETURN
930 P=K:IF N-K

940 C=U 950 FOR I=Z TO P-U 960 C=C/(I+U)*(N-I) 980 NEXT I 990 RETURN


You may also check:How to resolve the algorithm Babbage problem step by step in the Simula programming language
You may also check:How to resolve the algorithm Partition function P step by step in the Phix programming language
You may also check:How to resolve the algorithm Fibonacci sequence step by step in the Fe programming language
You may also check:How to resolve the algorithm Prime numbers whose neighboring pairs are tetraprimes step by step in the Julia programming language
You may also check:How to resolve the algorithm Non-decimal radices/Convert step by step in the Scheme programming language