Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Multiplication algorithm using Divide and Conquer approach … #465

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Python/20p-0598 Usama yazdani.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
a=str(input("Enter the first Value : ")) #taking input from users
b=str(input("Enter the second value : "))
result=0 # use this to storing final values
for i in range(0,len(a)): # loop 1 to get value
for j in range(0,len(b)):
val1=i #declaring value to calculate the "shift " first
val1+=1
val2=j
val2+=1 #staring with the next index bcz first value get multiplied
while(val1<len(a)): #calculating to first shift values
counter+=1
val1=val1+1
while(val2<len(b)):
counter+=1
val2=val2+1
c=(int(a[i])*int(b[j])) #multiple value and store in varaible
c=str(c) #changing into string bcz inserting 0's after it
while counter>0:
c=c+str(0) #loop to inserting zero
counter-=1
counter=0
result+=int(c) #adding final result


print("Final result is : ", result)