Find block number and floor by flat number
<p>Imagine - there's a house with 80 flats. It has 4 floors and 5 blocks. Each block has 4 flats.
User is asked to input flat number and Pascal program is supposed to calculate and output flat number. This must be calculated using some kind of formula. The only tip I have is that I have to use div and mod operations.</p>

<p>This is how the house looks like - <a href="https://i.stack.imgur.com/ugL4d.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ugL4d.png" alt="enter image description here"></a></p>

<p>So far, I've created program, that loops through all 80 flats and after each 16 flats increases block value and after each 4 blocks increases stair.</p>

<p>This is my code:</p>

<pre><code>program project1;
var
  i, floors, blocks, flats, flat, block, floor, blockCounter, floorCounter : integer;
begin
  floors := 4;
  blocks := 5;
  flats := 80;

  while true do
  begin
    write('Flat number: ');
    read(flat);

    block := 1;
    floor := 1;
    blockCounter := 0;
    floorCounter := 0;

    for i := 1 to 80 do
    begin
      blockCounter := blockCounter + 1;
      floorCounter := floorCounter + 1;
      if (floorCounter = 4) then
      begin
         floorCounter := 0;
         floor := floor + 1;
      end;

      if (blockCounter &gt; 16) then
      begin
         block := block + 1;
         blockCounter := 0;
         floorCounter := 0;
         floor := 1;
      end;

      if (i = flat) then
      begin
         writeln('Flat nr. ', flat, ' is in ', floor, '. floor and in ', block, '. block!');
      end;

    end;
  end;
end.
</code></pre>

<p>Is there anyone who can help me with this?</p>