How to resolve the algorithm Evaluate binomial coefficients step by step in the ERRE programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Evaluate binomial coefficients step by step in the ERRE 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 ERRE programming language
Source code in the erre programming language
PROGRAM BINOMIAL
!$DOUBLE
PROCEDURE BINOMIAL(N,K->BIN)
LOCAL R,D
R=1 D=N-K
IF D>K THEN K=D D=N-K END IF
WHILE N>K DO
R*=N
N-=1
WHILE D>1 AND (R-D*INT(R/D))=0 DO
R/=D
D-=1
END WHILE
END WHILE
BIN=R
END PROCEDURE
BEGIN
BINOMIAL(5,3->BIN)
PRINT("Binomial (5,3) = ";BIN)
BINOMIAL(100,2->BIN)
PRINT("Binomial (100,2) = ";BIN)
BINOMIAL(33,17->BIN)
PRINT("Binomial (33,17) = ";BIN)
END PROGRAM
You may also check:How to resolve the algorithm Count occurrences of a substring step by step in the REXX programming language
You may also check:How to resolve the algorithm Program termination step by step in the PL/I programming language
You may also check:How to resolve the algorithm Word frequency step by step in the Liberty BASIC programming language
You may also check:How to resolve the algorithm Terminal control/Clear the screen step by step in the Befunge programming language
You may also check:How to resolve the algorithm Vigenère cipher step by step in the Tcl programming language