aboutsummaryrefslogtreecommitdiff
path: root/challenge-090/paulo-custodio/python/ch-2.py
diff options
context:
space:
mode:
author冯昶 <seaker@qq.com>2021-03-15 18:18:09 +0800
committer冯昶 <seaker@qq.com>2021-03-15 18:18:09 +0800
commit5ed25077fde85262036c9db3e893d70ae0907b5c (patch)
tree8932d25b3fa6076e2d91ab2a331d4d8bfff20544 /challenge-090/paulo-custodio/python/ch-2.py
parent8b6be37fe4dac8b4c6489a95e55514b76b298d15 (diff)
parent65d54d52500028ec5359a7d39619803ade281543 (diff)
downloadperlweeklychallenge-club-5ed25077fde85262036c9db3e893d70ae0907b5c.tar.gz
perlweeklychallenge-club-5ed25077fde85262036c9db3e893d70ae0907b5c.tar.bz2
perlweeklychallenge-club-5ed25077fde85262036c9db3e893d70ae0907b5c.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-090/paulo-custodio/python/ch-2.py')
-rw-r--r--challenge-090/paulo-custodio/python/ch-2.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-090/paulo-custodio/python/ch-2.py b/challenge-090/paulo-custodio/python/ch-2.py
new file mode 100644
index 0000000000..29efd0d507
--- /dev/null
+++ b/challenge-090/paulo-custodio/python/ch-2.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+# Challenge 090
+#
+# TASK #2 > Ethiopian Multiplication
+# Submitted by: Mohammad S Anwar
+# You are given two positive numbers $a and $b.
+#
+# Write a script to demonstrate Ethiopian Multiplication using the given numbers.
+
+import sys
+
+def mul(a,b):
+ mul = 0
+ while True:
+ if (a & 1) != 0:
+ mul += b
+ if a <= 1:
+ break
+ a >>= 1
+ b <<= 1
+ return mul
+
+print(mul(int(sys.argv[1]), int(sys.argv[2])))