• Aucun résultat trouvé

if n=0 then

N/A
N/A
Protected

Academic year: 2022

Partager "if n=0 then"

Copied!
1
0
0

Texte intégral

(1)

>

>

>

>

>

>

>

>

>

>

>

>

Corrigé du TP Maple n°4 Exercice 1

restart:

facons:=proc(n)

option remember;

if n=1/4 then 1 elif n=1/2 then 2 elif n=3/4 then 3 elif n=1 then 6

else facons(n-1/4)+facons(n-1/2)+facons(n-1) end if;

end proc:

facons(10);

3587185688

Exercice 2

restart:

suiv:=proc(x)

option remember;

if x<5 then x+1 else min(2*suiv(iquo(x,2)),3*suiv(iquo (x,3)),5*suiv(iquo(x,5))) end if

end proc:

Hamming:=proc(k) # calcule le k-ième nombre de Hamming if k=1 then 1 else suiv(Hamming(k-1)) end if

end proc:

Hamming(101);

1600

Exercice 3

restart:

conv:=proc(n)

description "renvoie la liste des suites convenables commençant par n";

if n=0 then []

elif n=1 then [1]

else map(t->[n,op(t)],f(n-2)) end if

end proc:

f:=proc(n)

description "renvoie la liste des suites convenables commençant par k, 1<=k<=n";

if n=0 then [[]] else [op(conv(n)),op(f(n-1))] end if end proc:

conv(6);

6, 4, 2 , 6, 4, 1 , 6, 4 , 6, 3, 1 , 6, 3 , 6, 2 , 6, 1 , 6

Le nombre de suites convenables commençant par n est égal au n-ième nombre de Fibonacci.

Références

Documents relatifs

[r]

School of Mathematics and Statistics, Southwest University, Chongqing, 400715, People’s Republic of China – and – School of Mathematical Science, Kaili University, Kaili,

[r]

Iteration of rational functions was studied extensively by Fatou [3] and Julia [5] and the analogous theory for tran- scendental entire functions more briefly by Fatou

The purpose of this paper is to study the linear local connectivity of sets in Euclidean n-space in relation to their boundaries, and to prove that linear

BV analogy, might it not also be the case that the size of the Schwarzian derivative of a conformal mapping between two domains defines a good measure of their

Directeur: Frédéric Lenne - Editeur délégué: Michaëlle Pesah - REDACTION - Rédacteur en chef: Patrick Cheruette, Rédactrice: Julie Nicolas, Ont collaboré à ce numéro:.

[r]