From bc86275dae6188a2b8a20b518a82fad0196056e3 Mon Sep 17 00:00:00 2001 From: Amelia Whitlow Date: Mon, 6 Feb 2023 20:38:04 +0000 Subject: [PATCH 1/3] Added npr and cpr functions. --- scicalc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) mode change 100755 => 100644 scicalc diff --git a/scicalc b/scicalc old mode 100755 new mode 100644 index 1667b1d..6b626bb --- a/scicalc +++ b/scicalc @@ -48,6 +48,16 @@ def log10(x): return math.log10(x) +def npr(n,x): + """Return the number of permutations of x items out of n items""" + + return math.perm(n,x) + +def cpr(n,x): + """Return the number of combinations of x items out of n items""" + + return math.comb(n,x) + # # The dictionary that maps the command-line name of the operation, # to the function that performs it. There can be multiple names @@ -58,6 +68,10 @@ operators = { 'sum': add, 'mul': mul, 'log10': log10, + 'npr': npr, + 'perm' npr, + 'cpr': cpr, + 'comb': cpr, } if __name__ == "__main__": From 6a1c417cec216a16ac3e9266168c00c8cb098dbc Mon Sep 17 00:00:00 2001 From: Amelia Whitlow <49883911+ameliaWhitlow@users.noreply.github.com> Date: Mon, 6 Feb 2023 12:42:12 -0800 Subject: [PATCH 2/3] Update scicalc --- scicalc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scicalc b/scicalc index 6b626bb..537bdbd 100644 --- a/scicalc +++ b/scicalc @@ -68,10 +68,10 @@ operators = { 'sum': add, 'mul': mul, 'log10': log10, - 'npr': npr, - 'perm' npr, - 'cpr': cpr, - 'comb': cpr, + 'npr': npr, + 'perm' npr, + 'cpr': cpr, + 'comb': cpr, } if __name__ == "__main__": From 32696af7f2f0bcabf643ac6d9f7c472360eb47b4 Mon Sep 17 00:00:00 2001 From: Amelia Whitlow <49883911+ameliaWhitlow@users.noreply.github.com> Date: Mon, 6 Feb 2023 12:44:35 -0800 Subject: [PATCH 3/3] Update scicalc --- scicalc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scicalc b/scicalc index 537bdbd..470e259 100644 --- a/scicalc +++ b/scicalc @@ -69,8 +69,8 @@ operators = { 'mul': mul, 'log10': log10, 'npr': npr, - 'perm' npr, - 'cpr': cpr, + 'perm': npr, + 'cpr': cpr, 'comb': cpr, }