While1. The positive numbers A and B (A > B) are given. On the segment of length A, the maximum possible number of segments of length B (without overlays) is placed. Without using the operations of multiplication and division, find the length of the unoccupied part of the segment A.

Solution in Python 3:

import random

A = random.randrange(50,100)
B = random.randrange(1,A)
print('A = ', A)
print('B = ', B)

r = A - B
while r >= B:
r -= B
print("Remainder: ", r)