I have to develop a multiplication algorithm by adding to any integer in the most optimized way possible.
I thought of the following: x*y=z;x,y
belongs to integers, so z=x+x y
times. I know almost nothing about programming, but I managed to get on those lines:
n1 = int(input('Digite um número'))
n2= int(input('Digite um número'))
multiplicação = (n1 + n1) range (n2)
print("A multiplicação de", n1, "(n1 + n1) range (n", n2, "eh igual a", multiplicação)
My problem is that I can not set the multiplication law as n1+n1 n2
times. I need someone to give me a light on this, I just need that definition. The calculation should still be done in the most optimized way possible eg:
5.2=5+5
no:
5.2=2+2+2+2+2
If anyone has any idea of this also I would be extremely grateful.