• Aucun résultat trouvé

Devoirs et examens sur : www.Kiteb.net

N/A
N/A
Protected

Academic year: 2022

Partager "Devoirs et examens sur : www.Kiteb.net"

Copied!
2
0
0

Texte intégral

(1)

BAC Pratique Informatique 2016

Correction proposée par Mr KHARRAT Ala Eddine

Section : Sciences de l'Informatique

Program Fac_Prim;

Uses wincrt;

VAR

N:integer;

(***************** Saisie *****************) Procedure Saisie(VAR N:integer);

BEGIN

Repeat

Write('Entrer N : ');

Readln(N);

Until (N in [2..5]);

END;

(***************** Premier *****************) Function Premier(N:integer):boolean;

VAR

i,S:integer;

BEGIN S:=0;

for i:=2 to (N DIV 2) do If (N MOD i = 0) Then

S:=S+i;

Premier:= S=0;

END;

(***************** Factoriel *****************) Function Fact(N:integer):integer;

VAR

i,F:integer;

BEGIN F:=1;

for i:=2 to N do F:=F*i;

Fact:= F;

END;

(***************** Premier_Factoriel *****************) Function Premier_Factoriel(N:integer):boolean;

VAR

i:integer;

B:boolean;

BEGIN i:=0;

Repeat i:=i+1;

B:= (Fact(i)+1 = N) OR (Fact(i)-1 = N);

Until (B) OR (Fact(i)-1>N);

Premier_Factoriel:= (B) AND (Premier(N));

END;

(***************** Premier_Primoriel *****************) Function Premier_Primoriel(N:integer):boolean;

VAR

i:integer;

P:longint;

BEGIN P:=1;

i:=1;

Repeat i:=i+1;

If Premier(i) Then P:=P*i;

Until (P+1 = N) OR (P-1 = N) OR (P-1>N);

Premier_Primoriel:= ((P+1 = N) OR (P-1 = N)) AND (Premier(N));

END;

Devoirs et examens sur : www.Kiteb.net

(2)

BAC Pratique Informatique 2016

Correction proposée par Mr KHARRAT Ala Eddine

Section : Sciences de l'Informatique

(***************** Afficher_PF *****************) Procedure Afficher_PF(N:integer);

VAR

i,nb:integer;

BEGIN

nb:=0;

i:=1;

writeln('Les ',N,' premiers nombres "Premiers Factoriels" sont : ');

Repeat i:=i+1;

If Premier_Factoriel(i) Then BEGIN

nb:=nb+1;

writeln(nb,') ',i);

END;

Until (nb = N);

END;

(***************** Afficher_PP *****************) Procedure Afficher_PP(N:integer);

VAR

i,nb:integer;

BEGIN

nb:=0;

i:=1;

writeln('Les ',N,' premiers nombres "Premiers Primoriels" sont : ');

Repeat i:=i+1;

If Premier_Primoriel(i) Then BEGIN

nb:=nb+1;

writeln(nb,') ',i);

END;

Until (nb = N);

END;

(***************** Programme Principale *****************) BEGIN

Saisie(N);

Afficher_PF(N);

Afficher_PP(N);

END.

Devoirs et examens sur : www.Kiteb.net

Références

Documents relatifs

[r]

[r]

[r]

Selon les modèles de Malthus, à partir de quelle année ce pays ne serait plus en capacité de nourrir l’ensemble de sa population.. Exercice 2 : des taux

Pour chaque question, cocher sur cette feuille la ou les bonnes réponses dans la case prévue à cet effet. On note f ′′ la fonction dérivée seconde de la

Devoirs et examens sur : www.Kiteb.net... Devoirs et examens sur

[r]

[r]