Frage im Vorstellungsgespräch bei Bending Spoons

logic problems, algorithm questions involving loops