Created
December 25, 2021 16:06
-
-
Save 5war00p/d6ddd2c6eddda317f3122e2e5eacf002 to your computer and use it in GitHub Desktop.
Revisions
-
5war00p created this gist
Dec 25, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ def easy_mul(a,b): ''' params: int a int b return: int description: It finds multiplications of 2 numbers using the digit by digit of a multipler. ''' # finding lens a_len = len(str(a)) b_len = len(str(b)) # base condition if a_len == 1 or b_len: return a*b if a_len > b_len: lastdig_b = b % 10 new_b = b // 10 return (a*lastdig_b) + easy_mul(a, new_b) else: lastdig_a = a % 10 new_a = a // 10 return (lastdig_a * b) + easy_mul(new_a, b) if __name__ == '__main__': # taking inputs a = int(input('Enter number-1: ')) b = int(input('Enter number-2: ')) result = easy_mul(a, b) print(f'\n{a} * {b} = {result}\n')