Close Menu
Techs Slash

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    Why SaaS Growth Through Search Requires More Than Content Volume — And Why Seo For Saas Has to Get Smarter

    April 27, 2026

    Keansburg Facility Maintenance by Tech Services of NJ

    April 27, 2026

    Container Office for Sale and 40ft High Cube Container: What You Need to Knaow Before You Buy

    April 24, 2026
    Facebook X (Twitter) Instagram
    Techs Slash
    • Home
    • News
      • Tech
      • Crypto News
      • Cryptocurrency
    • Entertainment
      • Actors
      • ANGEL NUMBER
      • Baby Names
      • Beauty
      • beauty-fashion
      • facebook Bio
      • Fitness
      • Dubai Tour
    • Business
      • Business Names
    • Review
      • Software
      • Smartphones & Apps
    • CONTRIBUTION
    Facebook X (Twitter) Instagram
    Techs Slash
    Home»python»Armstrong Number in Python
    python

    Armstrong Number in Python

    Ranveer KumarBy Ranveer KumarOctober 22, 2022No Comments3 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email

    Warning: Trying to access array offset on value of type bool in /home/cadesimu/techsslash.com/wp-content/themes/smart-mag/partials/single/featured.php on line 78
    Share
    Facebook Twitter LinkedIn Pinterest Email

    We truly want to believe that you find the Armstrong Number in Python article as a main priority. We should continue on toward the articles.

    A number is called an Armstrong number on the off chance that the amount of blocks of digits of a number is equivalent to the actual number. In the beneath C program, we are checking regardless of whether the info number is Armstrong.

    Armstrong number is a number that is equivalent to the amount of 3D squares of its digits. For instance 0, 1, 153, 370, 371, and 407 are the Armstrong numbers.

    We should attempt to comprehend the reason why 153 is an Armstrong number.

    153 = (1*1*1)+(5*5*5)+(3*3*3)
    where:
    (1*1*1)=1
    (5*5*5)=125
    (3*3*3)=27
    So:
    1+125+27=153

    What is Armstrong Number?

    A three-digit number can be supposed to be an Armstrong number when the amount of all its singular digits blocks is equivalent to the actual number.

    Armstrong Number in Python using 3 digits

    At first, We can give the 3 digits of contribution to check regardless of whether the given info number is an Armstrong Number in the beneath program.

    # Python program to check if the number is an Armstrong number or not
    
    # take input from the user
    num = int(input("Enter a number: "))
    
    # initialize sum
    sum = 0
    
    # find the sum of the cube of each digit
    temp = num
    while temp > 0:
       digit = temp % 10
       sum += digit ** 3
       temp //= 10
    
    # display the result
    if num == sum:
       print(num,"is an Armstrong number")
    else:
       print(num,"is not an Armstrong number")
    

    Output

    Two types of inputs are given below to clear your doubts.

    Enter a number: 154
    154 is not an Armstrong number
    Enter a number: 153
    153 is an Armstrong number

    Armstrong Number in Python using n digits

    num = 1634
    
    # Changed num variable to string, 
    # and calculated the length (number of digits)
    order = len(str(num))
    
    # initialize sum
    sum = 0
    
    # find the sum of the cube of each digit
    temp = num
    while temp > 0:
       digit = temp % 10
       sum += digit ** order
       temp //= 10
    
    # display the result
    if num == sum:
       print(num,"is an Armstrong number")
    else:
       print(num,"is not an Armstrong number")
    

    Conclusion

    We really want to believe that you find the Armstrong Number in Python article extremely helpful. Assuming you have any questions you can ask your questions through the remark enclose this article

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Ranveer Kumar
    • Website

    Related Posts

    JSONDecodeError: Expecting value: line 1 column 1 (char 0)

    December 18, 2023

    Why does math.log result in ValueError: math domain error?

    December 17, 2023

    “inconsistent use of tabs and spaces in indentation” [duplicate]

    December 16, 2023
    Leave A Reply Cancel Reply

    Top Posts

    Sapne Me Nahane Ka Matlab

    March 18, 2024

    Sapne Me Nagn Stri Dekhna

    March 18, 2024

    Self Reliance: Release Date, Cast, Plot, Trailer, and More Information

    March 18, 2024

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    ABOUT TECHSSLASH

    Welcome to Techsslash! We're dedicated to providing you with the best of technology, finance, gaming, entertainment, lifestyle, health, and fitness news, all delivered with dependability.

    Our passion for tech and daily news drives us to create a booming online website where you can stay informed and entertained.

    Enjoy our content as much as we enjoy offering it to you

    Most Popular

    Sapne Me Nahane Ka Matlab

    March 18, 2024

    Sapne Me Nagn Stri Dekhna

    March 18, 2024

    Self Reliance: Release Date, Cast, Plot, Trailer, and More Information

    March 18, 2024
    CONTACT DETAILS

    Phone: +92-302-743-9438
    Email: contact@serpinsight.com

    Our Recommendation

    Here are some helpfull links for our user. hopefully you liked it.

    kakekmerah4d

    Techs Slash
    Facebook X (Twitter) Instagram Pinterest
    • Home
    • About us
    • contact us
    • Affiliate Disclosure
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • Write for us
    • Daman Game
    © 2026 Techsslash. All Rights Reserved

    Type above and press Enter to search. Press Esc to cancel.