The Ada Program: main.adb
1 -- main.adb: program to compute Jacobi symbol of user input
2
3 with Ada.Text_IO, Ada.Integer_Text_IO;
4 use Ada;
5
6 with Jacobi;
7
8 procedure Main is
9
10 A, N : Integer;
11
12 function GCD (X, Y : Natural) return Natural is
13 begin
14 if Y=0 then
15 return (X);
16 else
17 return (GCD (Y, X mod Y));
18 end if;
19 end GCD;
20
21
22 begin
23
24 Read: loop
25
26 Text_IO.Put ("Enter relatively prime integers A and N: ");
27 Integer_Text_IO.Get (A);
28 exit when A <= 0;
29
30 Integer_Text_IO.Get (N);
31 if N<=0 then
32 Text_IO.Put_Line ("N is less than or equal to zero.");
33 elsif GCD(A,N) = 1 then
34 Integer_Text_IO.Put (Jacobi (A, N));
35 Text_IO.New_Line;
36 else
37 Text_IO.Put_Line ("A and N are not relatively prime.");
38 end if;
39
40 end loop Read;
41
42 end Main;