Entri Blog
No Result
View All Result
Sunday, October 1, 2023
  • State PSC
    • Kerala PSC
      • Kerala PSC Exams
      • Kerala PSC Notification
      • Kerala PSC Exam Calender
      • Kerala PSC Previous Question papers
      • KAS Exam
      • KAS Previous Year Question papers
      • Kerala PSC VEO Notification
      • Kerala Police SI
      • Kerala PSC LDC Notification
      • Kerala PSC LP/UP Assistant
      • Kerala PSC Village Field Assistant Notification
      • Kerala PSC LD Typist Notification
      • Kerala PSC Food Safety Officer
      • Kerala PSC Excise Inspector Notification
      • Kerala PSC BDO Notification
      • Kerala PSC CPO Notification
      • Kerala PSC LGS Notification
    • TNPSC
    • APPSC
    • TSPSC
    • BPSC
    • Karnataka PSC
    • MPPSC
    • UPPSC
  • Banking
    • IBPS PO Notification
    • IBPS Clerk Notification
    • SBI PO Notification
    • SBI Clerk Notification
    • SBI SO Notification
    • SBI Apprentice Notification
    • Canara Bank PO Notification
    • Indian Bank PO Notification
    • RBI Assistant Notification
    • RBI Office Attendant Notification
    • IBPS RRB Notification
    • IBPS RRB Office Assistant Notification
  • Govt Exams
    • Railway
    • SSC
  • Skilling
    • Coding
    • Spoken English
    • Stock Marketing
  • Courses
    • Data Science Course
      • Data Science Malayalam
      • Data Science Training in Kochi
      • Data Science Training in Trivandrum
      • Data Science Course in Calicut
      • Data Science Training in Thrissur
    • Full Stack Developer Course
      • Full Stack Development Malayalam
      • Full Stack Development Hindi
      • Full Stack Development Tamil
      • Full Stack Development Telugu
      • Full Stack Development Kannada
    • Stock Market Course
      • Stock Market Course in Malayalam
      • Stock Market Course in Tamil
      • Stock Market Course in Kannada
      • Options Trading Course
    • Spoken English Course
      • Spoken English Course in Malayalam
      • Spoken English Course in Hindi
      • Spoken English Course in Telugu
      • Spoken English Course in Tamil
      • Spoken English Course in Kannada
    • Python Programming Course
    • Quantity Surveying Course
    • Performance Marketing Course
    • Practical Accounting Course
      • Tally Course
      • Taxation Course
      • UAE Accounting
      • GST Course
    • Mern Stack Developer Course
      • Full Stack Developer Course in Kochi
      • Full Stack Developer Course in Trivandrum
      • Full Stack Developer Course in Calicut
      • Full Stack Developer Course in Pune
      • Full Stack Developer Course in Bangalore
      • Full Stack Developer Course in Hyderabad
      • Full Stack Developer Course in Chennai
      • Full Stack Developer Course in Coimbatore
      • Full Stack Developer Course in Indore
      • Full Stack Developer Course in Jaipur
    • Other Courses
      • Montessori Teacher Training
      • MEP Course
      • German Language Course
      • OET Coaching
      • Nurses Recruitment Abroad
      • Digital Marketing Training
      • ChatGPT Course
      • Forex Trading Course
      • Yoga Teacher Training Course
  • Others
    • GATE
    • MAT
    • KMAT
    • UPSC
    • TET
      • APTET
      • CTET
      • DSSSB
      • Karnataka TET
      • Kerala TET
      • KVS
      • MPTET
      • SUPER TET
      • TNTET
      • TSTET
      • UPTET
  • Aptitude Questions
Spoken English
Entri Blog
  • State PSC
    • Kerala PSC
      • Kerala PSC Exams
      • Kerala PSC Notification
      • Kerala PSC Exam Calender
      • Kerala PSC Previous Question papers
      • KAS Exam
      • KAS Previous Year Question papers
      • Kerala PSC VEO Notification
      • Kerala Police SI
      • Kerala PSC LDC Notification
      • Kerala PSC LP/UP Assistant
      • Kerala PSC Village Field Assistant Notification
      • Kerala PSC LD Typist Notification
      • Kerala PSC Food Safety Officer
      • Kerala PSC Excise Inspector Notification
      • Kerala PSC BDO Notification
      • Kerala PSC CPO Notification
      • Kerala PSC LGS Notification
    • TNPSC
    • APPSC
    • TSPSC
    • BPSC
    • Karnataka PSC
    • MPPSC
    • UPPSC
  • Banking
    • IBPS PO Notification
    • IBPS Clerk Notification
    • SBI PO Notification
    • SBI Clerk Notification
    • SBI SO Notification
    • SBI Apprentice Notification
    • Canara Bank PO Notification
    • Indian Bank PO Notification
    • RBI Assistant Notification
    • RBI Office Attendant Notification
    • IBPS RRB Notification
    • IBPS RRB Office Assistant Notification
  • Govt Exams
    • Railway
    • SSC
  • Skilling
    • Coding
    • Spoken English
    • Stock Marketing
  • Courses
    • Data Science Course
      • Data Science Malayalam
      • Data Science Training in Kochi
      • Data Science Training in Trivandrum
      • Data Science Course in Calicut
      • Data Science Training in Thrissur
    • Full Stack Developer Course
      • Full Stack Development Malayalam
      • Full Stack Development Hindi
      • Full Stack Development Tamil
      • Full Stack Development Telugu
      • Full Stack Development Kannada
    • Stock Market Course
      • Stock Market Course in Malayalam
      • Stock Market Course in Tamil
      • Stock Market Course in Kannada
      • Options Trading Course
    • Spoken English Course
      • Spoken English Course in Malayalam
      • Spoken English Course in Hindi
      • Spoken English Course in Telugu
      • Spoken English Course in Tamil
      • Spoken English Course in Kannada
    • Python Programming Course
    • Quantity Surveying Course
    • Performance Marketing Course
    • Practical Accounting Course
      • Tally Course
      • Taxation Course
      • UAE Accounting
      • GST Course
    • Mern Stack Developer Course
      • Full Stack Developer Course in Kochi
      • Full Stack Developer Course in Trivandrum
      • Full Stack Developer Course in Calicut
      • Full Stack Developer Course in Pune
      • Full Stack Developer Course in Bangalore
      • Full Stack Developer Course in Hyderabad
      • Full Stack Developer Course in Chennai
      • Full Stack Developer Course in Coimbatore
      • Full Stack Developer Course in Indore
      • Full Stack Developer Course in Jaipur
    • Other Courses
      • Montessori Teacher Training
      • MEP Course
      • German Language Course
      • OET Coaching
      • Nurses Recruitment Abroad
      • Digital Marketing Training
      • ChatGPT Course
      • Forex Trading Course
      • Yoga Teacher Training Course
  • Others
    • GATE
    • MAT
    • KMAT
    • UPSC
    • TET
      • APTET
      • CTET
      • DSSSB
      • Karnataka TET
      • Kerala TET
      • KVS
      • MPTET
      • SUPER TET
      • TNTET
      • TSTET
      • UPTET
  • Aptitude Questions
No Result
View All Result
Entri Blog
Spoken Eng
  • HTML Tutorial
  • DSA Tutorials
  • Tutorials in Hindi
    • HTML Tutorial for Beginners in Hindi
    • Python Tutorial for Beginners in Hindi
    • GIT and GITHUB Tutorial for Beginners in Hindi
  • Tutorials in Tamil
    • JavaScript Tutorial in Tamil
  • Tutorials in Telugu
    • HTML Tutorial For Beginners in Telugu
    • CSS Tutorial for Beginners in Telugu
    • Bootstrap Tutorial for Beginner in Telugu
  • Tutorials in Kannada
    • HTML Tutorial For Beginners in Kannada
banner top article banner top article
Home Articles

Python Program to Check Armstrong Number

by Akhil M G
December 6, 2022
in Articles, Coding, Data Science and Machine Learning, Java Programming, React Native, Web and Android Development
Python Program to Check Armstrong Number
Share on FacebookShare on WhatsAppShare on Telegram

Table of Contents

  • What is an Armstrong Number?
  • Armstrong Number Logic
  • Armstrong Number Algorithm
  • Python Program To Check Armstrong Number
  • Program To Find All The Armstrong Numbers Between 0 and 999
  • Conclusion

What is an Armstrong Number?

According to mathematical number theory, the Armstrong number is any number that, when each of its digits is raised to the power of the number of digits in the number, generates the sum of the same number in every given number base.  Using the decimal system and the basic number 153 as an example, we can observe that it has 3 digits. By performing the straightforward mathematical procedure of increasing each of its digits to the power of three and then adding the resultant sum, we arrive at the number 153. That is 1 to the power of 3; 5 to the power of 3 times 3 times three equals 1 125 27 153. Additionally, this may be written as 13 53 33=153.

Python and Machine Learning Rectangle

Armstrong Number Logic

One must keep in mind that the Armstrong number characteristic holds true in all number systems in order to comprehend the logic of Armstrong nos. Take the six-digit number 548834 and check to see if it fits the Armstrong numbers property. Use the formula

5^6 4^6 8^6 8^6 3^6 4^6 =? Determine the amount by increasing each number to the power of six, then add the terms to determine the total. The sum, which is the actual number itself, is 548834. As a result, 548834 is an Armstrong number since it is the same when the individual terms of the number’s digits are added and raised to the power of the number’s digits. Consider the number 122 to see what Armstrong’s number is. Use the base-3 operation 13 23 23=17 to determine if 122 is an Armstrong no. The calculation is the same in base 3 as 2*1 2*3 1*9=17. It’s crucial to keep in mind that 3 to the power of 0 equals 1, 3 to the power of 1 equals 3, and 3 to the power of 2 equals 9. When adding all the words, we get 17. This means that, in any number system, an Armstrong number can display the same feature.

Learn to code from industry experts! Enroll here

Armstrong Number Algorithm

An Armstrong number algorithm uses two parameters to implement and validate the characteristic of what an Armstrong number is. The number of digits in the number is the first parameter in Armstrong number logic, and the second parameter is the sum of the terms when each digit is raised to the power of the number’s digits. For a better understanding, consider the Armstrong number algorithm:

Here are the 8 steps involved in a program for Armstrong number.

1. The number of digits in num is determined and found out.

2. The sum of digits of a number in Python or individual digit sums are got by performing num mod 10, where mod is called the remainder operation.

3. The individual digit is then raised to the power (number of digits) and stored.

4. The number is then divided by 10 in order to obtain the second digit.

5. All the above 3-steps numbered Steps 2, 3 and 4 are performed until the value of num is greater than 0.

6. When the num is less than 0, end the while loop.

7. Check the sum obtained or Armstrong value is the same as the original number

8. When yes, the number is labeled an Armstrong number

Python Program To Check Armstrong Number

Implementing the aforementioned procedure in Python as shown below will help you understand what the Armstrong number is in Python.

num= int(input(‘Enter a number: ‘))

num_original =num2=num

sum1 = 0

cnt=0

while(num>0):

cnt=cnt 1

num=num//10

while num2>0:

rem = num2% 10

sum1  = rem ** cnt

num2//= 10

if(num_original==sum1):

print(‘Armstrong!!’)

else:

print(‘Not Armstrong!’)

Output

Now in the field ‘Enter a number, enter the Armstrong number in python or number: 153. The output shows Armstrong number Python ‘Armstrong’.  Next try the algorithm with the field ‘Enter a number as 134 or Enter a number: 134. The output this time is, Not Armstrong!

To test the code, keep in mind that num original keeps the initial value of the input, whereas num stores the number of digits in the input. Sum 1=0 and cnt=0 are equivalent to 1 Armstrong. One may calculate the sum of each digit in the starting number raised to the power of the count variable using the variable num 2. Next, compare the original and sum to check if the original number displays the characteristics of an Armstrong number according to the Python Armstrong number program.

Program To Find All The Armstrong Numbers Between 0 and 999

The Armstrong numbers list produced by this application ranges from 0 to 999. A number is said to be Armstrong if the sum of its digits raised to the power of three equals the number itself. For instance, the number 371 is an Armstrong number as 3**3 + 7**3 + 1**3 = 371

PROGRAM  ArmstrongNumber

IMPLICIT  NONE

 

INTEGER :: a, b, c                   “the three digits”

INTEGER :: abc, a3b3c3               “the number and its cubic sum”

INTEGER :: Count                     “a counter”

 

Count = 0

DO a = 0, 9                          “for the left most digit”

DO b = 0, 9                       “for the middle digit”

DO c = 0, 9                         “for the right most digit”

abc    = a*100 + b*10 + c   !        “the number”

a3b3c3 = a**3 + b**3 + c**3 !        “the sum of cubes”

IF (abc == a3b3c3) THEN     !        “if they are equal”

Count = Count + 1        !           “count and display it”

WRITE(*,*)  ‘Armstrong number ‘, Count, ‘: ‘, abc

END IF

END DO

END DO

END DO

 

END PROGRAM  ArmstrongNumber

The output of the preceding program is shown below. There are six Armstrong numbers between 0 and 999.

Armstrong number 1: 0

Armstrong number 2: 1

Armstrong number 3: 153

Armstrong number 4: 370

Armstrong number 5: 371

Armstrong number 6: 407

Learn Coding in your Language! Enroll Here!

Conclusion

Here, one may learn about the Armstrong number, its Python implementation, and its algorithm. Are there any real-world uses for the special quality of Armstrong numbers then? There aren’t any in reality, and the uniqueness of these numbers serves no useful use other than as an example or a teaching tool to help students validate their programs, understand topics better, and investigate the laws of a new programming language.

Share62SendShare

Akhil M G

Related Posts

Kerala PSC Assistant Sub Inspector Notification 2023 PDF: Apply Link, Vacancy, Eligibility
Articles

Kerala PSC Assistant Sub Inspector (ASI) Notification 2023 PDF: Apply Link, Vacancy, Eligibility

September 27, 2023
Kerala PSC Store Keeper Notification 2023 Out: Apply Link, Eligibility, Vacancy
Articles

Kerala PSC Store Keeper Notification 2023: Apply Link, Eligibility, Vacancy

September 27, 2023
Kerala PSC LD Typist Notification 2023 - Vacancy, Salary, Eligibility
Articles

Kerala PSC LD Typist Notification 2023 PDF: Apply Link, Vacancy, Eligibility

September 27, 2023
Next Post
Final Result of SSC Stenographer 2020 Out @ssc.nic.in - Check Result PDF Here

Final Result of SSC Stenographer 2020 Out @ssc.nic.in - Check Result PDF Here

More to Explore

  1. Future Scope of Full Stack Developers
  2. Best Full Stack Developer Course with Placement
  3. Python Full Stack vs Java Full Stack Developers
  4. Top Trends in Full Stack Development Career
  5. Guide to Full Stack Web Development – Skills, Career Opportunities, Salary
  6. Full Stack Developer Salary for Freshers and Experienced
  7. Full Stack Developer Jobs and Career to Follow
  8. Full Stack JavaScript Development

Free Tutorials For You

  1. SQL Tutorial for Beginners PDF
  2. Python Tutorial for Beginners in Hindi
  3. GIT and GITHUB Tutorial for Beginners in Hindi
  4. HTML Exercises to Practice
  5. JavaScript Tutorial in Tamil
  6. DSA Practice Series
  7. Microsoft Excel Malayalam Tutorial
  8. Learn Bootstrap in Tamil
  9. Introduction to CSS in Malayalam
  10. Introduction to JavaScript in Malayalam
  11. Java Programming Notes PDF
  12. Introduction to HTML in Malayalam

Full Stack Training in Different Cities

  1. Full Stack Developer Course in Kochi
  2. Full Stack Developer Course in Trivandrum
  3. Full Stack Developer Course in Calicut
  4. Full Stack Developer Course in Pune
  5. Full Stack Developer Course in Bangalore
  6. Full Stack Developer Course in Hyderabad
  7. Full Stack Developer Course in Chennai
  8. Full Stack Developer Course in Coimbatore
  9. Full Stack Developer Course in Indore
  10. Full Stack Developer Course in Jaipur
  11. Full Stack Developer Course in Mumbai

More to Learn

  1. Top C++ Interview Questions and Answers
  2. Top 100 C# Interview Questions and Answers
  3. Top 100 Angular Interview Questions and Answers
  4. Interview Questions and Answers for Web Development
  5. Career Options after Engineering

Courses

  • Data Science Course
  • Full Stack Developer Course
  • Data Science Course in Malayalam
  • Full Stack Developer Course in Malayalam
  • Full Stack Developer Course in Hindi
  • Full Stack Developer Course in Tamil
  • Full Stack Developer Course in Telugu
  • Full Stack Developer Course in Kannada
  • Python Programming Course
  • Practical Accounting Course
  • Quantity Surveying Course
  • Stock Market Course
  • Stock Market Course in Malayalam
  • Stock Market Course in Tamil
  • Stock Market Course in Kannada
  • Options Trading Course

Company

  • Become a teacher
  • Login to Entri Web

Spoken English Courses

  • Spoken English Course
  • Spoken English Course in Malayalam
  • Spoken English Course in Hindi
  • Spoken English Course in Tamil
  • Spoken English Course in Telugu
  • Spoken English Course in Kannada
  • Spoken English Course for Housewives
  • Spoken English Course for Working Professionals
  • Spoken English Course for School Students
  • Spoken English Course for College Students
  • Spoken English Course for Job Seekers
  • AI Powered Spoken English Course

Quick Links

  • Aptitude Questions
  • Articles
  • Videos
  • Entri Daily Quiz Practice
  • Current Affairs & GK
  • News Capsule – eBook
  • Preparation Tips
  • Kerala PSC Gold
  • Entri Skilling
  • Kerala PSC

Other Courses

  • OET Coaching Classes
  • Nurse Recruitment Abroad
  • Forex Trading Course
  • Montessori Teachers Training
  • Performance Marketing Course
  • German Language Course
  • MEP Course

Popular Exam

  • IBPS Exam
  • SBI Exam
  • Railway RRB Exam
  • Kerala PSC
  • Tamil Nadu PSC
  • Telangana PSC
  • Andhra Pradesh PSC
  • MPPSC
  • UPPSC
  • Karnataka PSC
  • Staff Selection Commission Exam

© 2021 Entri.app - Privacy Policy | Terms of Service

No Result
View All Result
  • State PSC
    • Kerala PSC
      • Kerala PSC Exams
      • Kerala PSC Notification
      • Kerala PSC Exam Calender
      • Kerala PSC Previous Question papers
      • KAS Exam
      • KAS Previous Year Question papers
      • Kerala PSC VEO Notification
      • Kerala Police SI
      • Kerala PSC LDC Notification
      • Kerala PSC LP/UP Assistant
      • Kerala PSC Village Field Assistant Notification
      • Kerala PSC LD Typist Notification
      • Kerala PSC Food Safety Officer
      • Kerala PSC Excise Inspector Notification
      • Kerala PSC BDO Notification
      • Kerala PSC CPO Notification
      • Kerala PSC LGS Notification
    • TNPSC
    • APPSC
    • TSPSC
    • BPSC
    • Karnataka PSC
    • MPPSC
    • UPPSC
  • Banking
    • IBPS PO Notification
    • IBPS Clerk Notification
    • SBI PO Notification
    • SBI Clerk Notification
    • SBI SO Notification
    • SBI Apprentice Notification
    • Canara Bank PO Notification
    • Indian Bank PO Notification
    • RBI Assistant Notification
    • RBI Office Attendant Notification
    • IBPS RRB Notification
    • IBPS RRB Office Assistant Notification
  • Govt Exams
    • Railway
    • SSC
  • Skilling
    • Coding
    • Spoken English
    • Stock Marketing
  • Courses
    • Data Science Course
      • Data Science Malayalam
      • Data Science Training in Kochi
      • Data Science Training in Trivandrum
      • Data Science Course in Calicut
      • Data Science Training in Thrissur
    • Full Stack Developer Course
      • Full Stack Development Malayalam
      • Full Stack Development Hindi
      • Full Stack Development Tamil
      • Full Stack Development Telugu
      • Full Stack Development Kannada
    • Stock Market Course
      • Stock Market Course in Malayalam
      • Stock Market Course in Tamil
      • Stock Market Course in Kannada
      • Options Trading Course
    • Spoken English Course
      • Spoken English Course in Malayalam
      • Spoken English Course in Hindi
      • Spoken English Course in Telugu
      • Spoken English Course in Tamil
      • Spoken English Course in Kannada
    • Python Programming Course
    • Quantity Surveying Course
    • Performance Marketing Course
    • Practical Accounting Course
      • Tally Course
      • Taxation Course
      • UAE Accounting
      • GST Course
    • Mern Stack Developer Course
      • Full Stack Developer Course in Kochi
      • Full Stack Developer Course in Trivandrum
      • Full Stack Developer Course in Calicut
      • Full Stack Developer Course in Pune
      • Full Stack Developer Course in Bangalore
      • Full Stack Developer Course in Hyderabad
      • Full Stack Developer Course in Chennai
      • Full Stack Developer Course in Coimbatore
      • Full Stack Developer Course in Indore
      • Full Stack Developer Course in Jaipur
    • Other Courses
      • Montessori Teacher Training
      • MEP Course
      • German Language Course
      • OET Coaching
      • Nurses Recruitment Abroad
      • Digital Marketing Training
      • ChatGPT Course
      • Forex Trading Course
      • Yoga Teacher Training Course
  • Others
    • GATE
    • MAT
    • KMAT
    • UPSC
    • TET
      • APTET
      • CTET
      • DSSSB
      • Karnataka TET
      • Kerala TET
      • KVS
      • MPTET
      • SUPER TET
      • TNTET
      • TSTET
      • UPTET
  • Aptitude Questions

© 2021 Entri.app - Privacy Policy | Terms of Service