package body Arithmetic is
   procedure Divide (N, D : Natural; Q, R : out Natural) is
   begin
      Q := 0;
      R := N;
      while R >= D loop
         pragma Loop_Invariant (Q * D + R = N and Q <= N);
         pragma Loop_Variant (Decreases => R);
         Q := Q + 1;
         R := R - D;
      end loop;
   end Divide;

   function GCD (A, B : Natural) return Natural is
   begin
      if B = 0 then
         return A;
      else
         return GCD (B, A mod B);
      end if;
   end GCD;

   function Power (Base : Integer; Exponent : Natural) return Integer is
      Result : Integer := 1;
   begin
      for I in 1 .. Exponent loop
         pragma Loop_Invariant (To_Big_Integer (Result) = To_Big_Integer (Base) ** (I - 1));
         Result := Result * Base;
         pragma Annotate (GNATprove, False_Positive, "overflow check might fail",
                          "Base ** I <= abs Base ** Exponent; Verada proves it, GNATprove's provers time out");
      end loop;
      return Result;
   end Power;
end Arithmetic;
