--Autore: Treppiedi Luigi --Esercizio 3.1 --Il programma calcola i primi Last(cambiare la costante per ottenere --piu' numeri) numeri primi with Ada.Integer_Text_Io,Ada.Text_Io; use Ada.Integer_Text_Io,Ada.Text_Io; procedure Numeriprimi2 is Last :constant Integer:=1000; X,N :Integer:=1; Cont :Integer:=0; Conta :Integer:=0; type Nprimi is array(1..Last) of Integer; Primo :Nprimi:=(others=>0); begin Primo(1):=2; Conta:=Conta+1; loop N:=N+1; X:=X+Cont; Cont:=0; loop if N mod Primo(X)=0 then exit; else if X-1=0 then X:=X+Cont+1; Cont:=0; Primo(X):=N; Conta:=Conta+1; exit; else X:=X-1; Cont:=Cont+1; end if; end if; end loop; exit when Conta=Last; end loop; for I in Integer range 1..Last loop Put(Primo(I),6); if I mod 12 =0 then --serve per fare le colonne New_Line; end if; end loop; end Numeriprimi2;