-- $Id: nestedloop.gnat,v 1.0 2003/06/11 12:04:00 dada Exp $
-- http://dada.perl.it/shootout/
-- Ada 95 code by C.C.

with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Command_Line;

procedure NestedLoop is
   Count, M : Natural := 0;
   N        : Positive := 1;
begin
   begin
      N := Positive'Value (Ada.Command_Line.Argument (1));
   exception
      when Constraint_Error => null;
   end;
   M := N - 1;
   for A in 0 .. M loop
      for B in 0 .. M loop
         for C in 0 .. M loop
            for D in 0 .. M loop
               for E in 0 .. M loop
                  for F in 0 .. M loop
                     Count := Count + 1;
                  end loop;
               end loop;
            end loop;
         end loop;
      end loop;
   end loop;
   Ada.Integer_Text_IO.Put (Item => Count, Width => 0);
   Ada.Text_IO.New_Line;
end NestedLoop;