a
Middle
School
Grade 6
Grade 7
Grade 8
Grade 9
Ressource
Out Middle
High
School
Grade 10
Grade 11
Grade 11 - STMG
Grade 12 - STMG
Grade 12
Grade 12 - Comp.
Grade 12 - Exp.
Ressource
Out High
4
3
2
1
Outside the middle school program
/ Some algorithms
3 exercises corrected
a
Algorithms and AlgoBox
(3 exercices)
1.
Algorithms
and
AlgoBox
E.3392
1
In
the
programming
language
of
your
choice,
enter
the
function
below
:
Function
f(a)
For
i
ranging
from
1
to
100
c
←
remainder
of
the
division
euclidean
of
a
by
b
End
For
2
Running
a
step-by-step
execution
of
the
function
f
with
the
argument
b
=
3
,
what
are
the
values
assigned
to
the
variable
c
.
E.3390
The
program
below
represents
the
P
GC
D
algorithm
by
successive
subtraction
for
AlgoBox
soft-
ware.
Function
f(a,b)
As
long
as
a
−
b
=
0
M
←
max(a;b)
b
←
min(a;
b)
a
←
M
c
←
a
−
b
a
←
c
End
As
long
as
1
Write
this
program
in
the
language
of
your
choice.
2
Call
the
function
f
with
the
values
a
=
541
and
b
=
24
.
When
calling
this
function
f
step
by
step
in
the
algo-
rithm,
note
the
values
of
the
variables
a
,
b
and
c
at
each
end
of
loop
execution.
E.3391
Here
is
a
diagram
showing
Euclid’s
al-
gorithm
:
1
In
the
table
below,
determine
the
GC
D
of
the
numbers
541
and
24
:
A
B
r
2
Hier
ist
eine
Schreibweise
dieses
Algorithmus
durch
die
Funktion
f
,
die
zwei
natürliche
Zahlen
als
Argumente
nimmt.
Function
f(a,b)
While
...
r
←
remainder
of
the
Euclidean
division
of
a
and
b
a
←
...
b
←
...
End
While
r
←
0
Return
b
Complete
the
missing
parts
of
this
algorithm.
https://chingmath.fr
chapExoCorrec/3392
sacados/3392
chapExoCorrec/3390
sacados/3390
chapExoCorrec/3391
sacados/3391
A
et
B
deux nombres
Le
reste
de
la
division
de
A
par
B
vaut 0?
Le PGCD est
B
ˆ
A
prend pour valeur
B
ˆ
B
prend pour valeur
r
On e∑ectue la division euclidienne de
A
par
B
Oui
Non
A
B
C
D
1
D
2
ChingMath
by ChingLab
©
Middle School
Grade 6
Grade 7
Grade 8
Grade 9
High School
Grade 10
Grade 11
Grade 12
Grade 12 opt. Complémentaire
Grade 12 opt. Experte
Various
Contact me
F.A.Q
Other website
ChingWeb