aboutsummaryrefslogtreecommitdiff
path: root/challenge-082/pkmnx/gnat/ch_1.adb
blob: c086facc68bf471cd2ee0cfd0a71e708e8e6b57d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
with ada.command_line; use ada.command_line;
with ada.Text_IO; use ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure ch_1 is
   M : Long_Integer := Long_Integer'Value(argument (1));
   N : Long_Integer := Long_Integer'Value(argument (2));
   p : Long_Integer := 0;
   gcd : Long_Integer := 0;
   i : Long_Integer := 0;
begin

   gcd := N;

   while (M /= 0) loop
      p := gcd;
      gcd := M;
      M := p mod M;
   end loop;

   for i in 1 .. gcd loop
      if ( ( gcd mod i ) = 0 ) then
         put( Long_Integer'Image(i) );
      end if;
   end loop;

end ch_1;