Exercise 05-08:

Write a program that reads two numbers. Print the result of multiplying the first by the second. Use only the addition and subtraction operators to calculate the result. Remember that we can understand the multiplication of two numbers as successive sums of one of them (e.g., 4 × 5 = 5 + 5 + 5 + 5 = 4 + 4 + 4 + 4 + 4).

Answer:

##############################################################################
# Python From Scratch
# Author: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2025 - LogiKraft 2025
# Site: https://pythonfromscratch.com
# ISBN: 978-85-7522-949-1 (Paperback), 978-85-7522-950-7 (hardcover), 978-85-7522-951-4 (ebook)
#
# File: chapter 05/exercise-05-08.py.py
##############################################################################
first = int(input("First number: "))
second = int(input("Second number: "))
x = 1
result = 0
while x <= second:
    result = result + first
    x = x + 1
print(f"{first} x {second} = {result}")
Click here to download the file