src/HOL/SPARK/Examples/Sqrt/Sqrt.adb
author blanchet
Fri, 14 Feb 2014 07:53:46 +0100
changeset 55469 b19dd108f0c2
parent 41561 d1318f3c86ba
permissions -rw-r--r--
aligned the syntax for 'free_constructors' on the 'datatype_new' and 'codatatype' syntax

package body Sqrt is

   function Isqrt(N: Natural) return Natural
   is
     R: Natural;
   begin
      R := 0;
      loop
         --# assert R * R <= N;
         exit when N - R * R < 2 * R + 1;
         R := R + 1;
      end loop;
      return R;
   end Isqrt;

end Sqrt;