.TITLE Permutation ; Calculation of P(N,R) - the number of permutations ; of N things taken R at a time using a function for ; evaluation of Factorials ; Method: Calculate P(N,R) using N!/(N - R)! .DISABLE GLOBAL ; Uses external function Factorial .EXTERNAL Factorial ; Program Variables: N: .LONG 5 R: .LONG 2 PNR: .BLKL 1 ; P(N,R) NMinusR: .BLKL 1 ; N - R ; The main program: .ENTRY Permutations, 0 ; R3 <-- N! Start: PUSHAL N ; Push address of N CALLS #1, Factorial ; Calculate N! MOVL R0, R3 ; Save N! ; R0 <-- (N - R)! SUBL3 R, N, NMinusR ; Calculate N - R PUSHAL NMinusR ; Push address N - R CALLS #1, Factorial ; Calculate (N - R)! ; P(N,R) <-- quotient DIVL3 R0, R3, PNR Finish: $EXIT_S .END Permutations