armstrong number python program

Publié le: 19 janvier 2023
sur la chaîne: Daily Tutorials
2,362
38

This program defines a function is_armstrong_number() that takes an integer num as input and returns True if the number is an Armstrong number, and False otherwise.
It works by first converting the number to a string, so that each digit can be accessed individually.
It then initializes a variable length to store the number of digits in the number, and a variable sum to store the sum of each digit raised to the power of length.
It then iterates through each character in the string, converts it to an integer, raises it to the power of length, and adds it to the sum.
Finally, it checks if the sum is equal to the original number, and returns True if it is, and False otherwise.


Sur cette page du site, vous pouvez voir la vidéo en ligne armstrong number python program durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Daily Tutorials 19 janvier 2023, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 2,362 fois et il a aimé 38 téléspectateurs. Bon visionnage!