AlgoBox : Définition puissance Cet algorithme calcule la puissance
Transcription
AlgoBox : Définition puissance Cet algorithme calcule la puissance
AlgoBox : Définition puissance Cet algorithme calcule la puissance n d'un nombre a lorsque a est un nombre réel et n est un entier relatif en utilisant comme seules opérations la multiplication *, la division / et le calcul de l'opposé d'un nombre ( -n : opposé de n ) Code de l'algorithme 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 31 VARIABLES a EST_DU_TYPE NOMBRE n EST_DU_TYPE NOMBRE k EST_DU_TYPE NOMBRE p EST_DU_TYPE NOMBRE DEBUT_ALGORITHME LIRE a LIRE n AFFICHER a AFFICHER "^" AFFICHER n AFFICHER " = " p PREND_LA_VALEUR 1 SI (n>0) ALORS DEBUT_SI POUR k ALLANT_DE 1 A n DEBUT_POUR p PREND_LA_VALEUR p*a FIN_POUR FIN_SI SI (n<0) ALORS DEBUT_SI n PREND_LA_VALEUR -n POUR k ALLANT_DE 1 A n DEBUT_POUR p PREND_LA_VALEUR p*a FIN_POUR p PREND_LA_VALEUR 1/p FIN_SI AFFICHER p FIN_ALGORITHME Résultats ***Algorithme lancé*** Entrer a : 2 Entrer n : -3 2^-3 = 0.125 ***Algorithme terminé*** Généré par AlgoBox