E questo? :master:Originariamente inviato da cso
Forse è megliocodice:program compito_6; uses crt; var i,num:integer; begin clrscr; repeat write('inserisci un numero: '); readln(num); until num>0; writeln; if num=2 then writeln('il numero Š primo!') else if num=3 then writeln('il numero Š primo!') else begin i:=0; if num mod 2=0 then i:=i+1; if num mod 3=0 then i:=i+1; if i=0 then writeln('il numero Š primo!'); if i>=1 then writeln('il numero non Š primo!'); end; readln; end.![]()
Calma... non è che un numero sia primo se non è divisibile né per 2 né per 3... ma se non ha divisori diversi da 1 e da se stesso... :master:
Ciao.![]()