La machine ZZ Vous avez peut-être déjà vu ou utilisé par le passé l’algorithme de la machine ZZ présenté ci dessous : La machine ZZ fonctionne de la manière suivante : n . 2 3n + 1 • Si le nombre introduit n est impair, alors k = . 2 • Si le nombre introduit n est pair, alors k = Détail de l’algorithme : L’écrire en langage algorithmique... 1 La machine ZZ Avec Algobox : En langage algorithmique : Algorithme MACHINE ZZ Variable n:nombre k :nombre Début Lire(n) k← n TantQue k 6=1 Faire Si n pair Alors k← n2 Afficher k Si k 6=1 Alors n← k FinSi Sinon k← 3n+1 2 Afficher k Si k 6=1 Alors n← k FinSi FinSi FinTantQue Fin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 2 VARIABLES n EST_DU_TYPE NOMBRE k EST_DU_TYPE NOMBRE DEBUT_ALGORITHME LIRE n k PREND_LA_VALEUR n TANT_QUE (k!=1) FAIRE DEBUT_TANT_QUE SI (n%2==0) ALORS DEBUT_SI k PREND_LA_VALEUR n/2 AFFICHER " k= " AFFICHER k SI (k!=1) ALORS DEBUT_SI n PREND_LA_VALEUR k FIN_SI FIN_SI SINON DEBUT_SINON k PREND_LA_VALEUR (3*n+1)/2 AFFICHER " k= " AFFICHER k SI (k!=1) ALORS DEBUT_SI n PREND_LA_VALEUR k FIN_SI FIN_SINON FIN_TANT_QUE FIN_ALGORITHME