

{"id":173223,"date":"2022-06-16T10:40:50","date_gmt":"2022-06-16T05:10:50","guid":{"rendered":"https:\/\/www.jigsawacademy.com\/?p=173223"},"modified":"2022-09-26T12:43:21","modified_gmt":"2022-09-26T07:13:21","slug":"blogs-data-science-what-is-armstrong-number","status":"publish","type":"post","link":"https:\/\/www.jigsawacademy.com\/blogs\/data-science\/what-is-armstrong-number\/","title":{"rendered":"What is Armstrong Number? An Interesting Overview (2022)"},"content":{"rendered":"\r\n<h2><strong>Introduction<\/strong><\/h2>\r\n\r\n\r\n\r\n<ol>\r\n<li><a class=\"rank-math-link\" href=\"#What-is-Armstrong-Number?\"><strong>What is Armstrong Number?<\/strong><\/a><\/li>\r\n<li><a class=\"rank-math-link\" href=\"#Armstrong-Number-Logic\"><strong>Armstrong Number Logic<\/strong><\/a><\/li>\r\n<li><a class=\"rank-math-link\" href=\"#Armstrong-number-examples\"><strong>Armstrong number examples<\/strong><\/a><\/li>\r\n<li><a class=\"rank-math-link\" href=\"#Armstrong-Number-Algorithm\"><strong>Armstrong Number Algorithm<\/strong><\/a><\/li>\r\n<li><strong><a class=\"rank-math-link\" href=\"#Python-program-to-check-Armstrong-Number:\">Python program to check Armstrong Number<\/a><\/strong><\/li>\r\n<li><strong><a href=\"#Program-To-Find-All-The-Armstrong-Numbers-Between-0-And-999\">Program To Find All The Armstrong Numbers Between 0 And 999<\/a><\/strong><\/li>\r\n<\/ol>\r\n\r\n\r\n\r\n<h2 id=\"What-is-Armstrong-Number?\" class=\"has-vivid-cyan-blue-color has-text-color\"><strong>1) What is Armstrong Number?<\/strong><\/h2>\r\n<!-- New Code starts -->\r\n<p><a class=\"all-link\"><img decoding=\"async\" class=\"blog-desk-banner\" src=\" https:\/\/www.jigsawacademy.com\/wp-content\/uploads\/2022\/06\/DSML_Banner2.webp\" alt=\"Desktop Banner\" title=\"\"> <img decoding=\"async\" class=\"blog-mob-banner\" src=\"https:\/\/www.jigsawacademy.com\/wp-content\/uploads\/2022\/06\/DSML_Floating.webp \" alt=\"Mobile Banner\" title=\"\"><\/a><\/p>\r\n<!-- New Code Ends -->\r\n\r\n\r\n<p>Beginners often wonder\u00a0what is Armstrong number\u00a0aka the narcissist number. It is of special interest to new programmers and those learning a new programming language because of the way the number behaves in a given number base. In numerical number theory, the\u00a0Armstrong number definition\u00a0is the number in any given number base, which forms the total of the same number, when each of its digits is raised to the power of the number of digits in the number.<\/p>\r\n\r\n\r\n\r\n<p>For example, using a simple number 153 and the decimal system, we see there are 3 digits in it. If we do a simple mathematical operation of raising each of its digits to the power of 3, and then totalling the sum obtained, we get 153. That is 1 to the power of 3 5 to the power of 3 3 to the power of three is 1 125 27 153. This can also be represented as 1^3 5^3 3^3=153. The number 153 is an\u00a0example of the Armstrong number\u00a0which also has a unique property that one can use any number system.<\/p>\r\n\r\n\r\n\r\n<p>Thus if the number obtained totals to or equals the original number when each of the digits is raised to the power of the number of digits in the number and added to obtain a number, in any given number system, such a number is called an\u00a0Armstrong number.<\/p>\r\n\r\n\r\n\r\n<h2 id=\"Armstrong-Number-Logic\" class=\"has-vivid-cyan-blue-color has-text-color\">2) <strong>Armstrong Number Logic<\/strong><\/h2>\r\n\r\n\r\n\r\n<p>To understand the logic of\u00a0Armstrong nos,\u00a0one needs to remember that the Armstrong number property is true in any number system. Let us take the number 548834 with 6 digits and see if it satisfies the property of Armstrong numbers. Use the equation<\/p>\r\n\r\n\r\n\r\n<p>\u00a05^6 4^6 8^6 8^6 3^6 4^6 =? Calculate the sum obtained by raising each of the digits to the power of six and adding together the sum of the terms obtained. The total is 548834 which is the original number itself. Thus 548834 is an Armstrong number since one gets the same number when one adds the individual terms of the digits in the number raised to the power of the number of digits in the number.\u00a0<\/p>\r\n\r\n\r\n\r\n<p>Let us look at what is Armstrong number\u00a0by taking the number 122. In base 3 to check if 122 is an Armstrong no, perform the operation 1^3 2^3 2^3=17. In base 3 the operation is the same as 2<em>*1 2<\/em>*3 1*9=17. Important to note here is that 3 to the power of zero is equal to 1, and 3 to the power of 1 is 3, and 3 to the power of two is 9. Totalling the terms obtained we get 17. This means that an Armstrong number can exhibit the same property in any given number system.<\/p>\r\n\r\n\r\n\r\n<h2 id=\"Armstrong-number-examples\" class=\"has-vivid-cyan-blue-color has-text-color\">3) <strong>Armstrong number examples<\/strong><\/h2>\r\n\r\n\r\n\r\n<p>0, 1, 153, 370, 371 and 407 are an\u00a0Armstrong number list\u00a0or all examples of Armstrong numbers. Let us check why?<\/p>\r\n\r\n\r\n\r\n<p>\u00a0For 0, the operation is 0^1=0<\/p>\r\n\r\n\r\n\r\n<p>\u00a0For 1, the operation is 1^1=1<\/p>\r\n\r\n\r\n\r\n<p>\u00a0For 153, the operation is 1^3 5^3 3^3=153<\/p>\r\n\r\n\r\n\r\n<p>\u00a0For 370 the operation is 3^3 7^3 0^3=370<\/p>\r\n\r\n\r\n\r\n<p>\u00a0For 371 the operation is 3^3 7^3 1^3=371<\/p>\r\n\r\n\r\n\r\n<p>\u00a0For 407 the operation is 4^3 0^3 7^3=407<\/p>\r\n\r\n\r\n\r\n<p>Let us now look at what is Armstrong number behavior with a 4 digit Armstrong number. The operation involves raising each of the digits to the power of 4 and then totaling the terms obtained. Armstrong numbers with 4 digits are 1634, 8208, and 9474 among others. Armstrong numbers between 1 to 10000 can easily be found following these rules.<\/p>\r\n\r\n\r\n\r\n<h2 id=\"Armstrong-Number-Algorithm\" class=\"has-vivid-cyan-blue-color has-text-color\">4) <strong>Armstrong Number Algorithm<\/strong><\/h2>\r\n<!-- New Code starts -->\r\n<p><a class=\"all-link\"><img decoding=\"async\" class=\"blog-desk-banner\" src=\"https:\/\/www.jigsawacademy.com\/wp-content\/uploads\/2022\/06\/DSML_Banner1.webp\" alt=\"Desktop Banner\" title=\"\"> <img decoding=\"async\" class=\"blog-mob-banner\" src=\"https:\/\/www.jigsawacademy.com\/wp-content\/uploads\/2022\/06\/DSML_2_Mobile-1.png\" alt=\"Mobile Banner\" title=\"\"><\/a><\/p>\r\n<!-- New Code Ends -->\r\n\r\n\r\n<p>There are two parameters to implement and verify the property of what is Armstrong number by an\u00a0Armstrong number algorithm.\u00a0The first parameter in\u00a0Armstrong number logic\u00a0is the number\u2019s number of digits and the second parameter is the sum of the terms when each of its digits is raised to the power of the number of digits in the number. Take a look at the Armstrong number algorithm to obtain a better understanding:<\/p>\r\n\r\n\r\n\r\n<p>Here are the 8 steps involved in a\u00a0program for Armstrong number.<\/p>\r\n\r\n\r\n\r\n<p>1. The number of digits in num is determined and found out.<\/p>\r\n\r\n\r\n\r\n<p>\u00a02. The\u00a0sum of digits of a number in Python\u00a0or individual digit sums are got by performing num mod 10, where mod is called the remainder operation.<\/p>\r\n\r\n\r\n\r\n<p>\u00a03. The individual digit is then raised to the power (number of digits) and stored.<\/p>\r\n\r\n\r\n\r\n<p>\u00a04. The number is then divided by 10 in order to obtain the second digit.<\/p>\r\n\r\n\r\n\r\n<p>\u00a05. All the above 3-steps numbered Steps 2, 3 and 4 are performed until the value of num is greater than 0.<\/p>\r\n\r\n\r\n\r\n<p>\u00a06. When the num is less than 0, end the while loop.<\/p>\r\n\r\n\r\n\r\n<p>\u00a07. Check the sum obtained or\u00a0Armstrong value\u00a0is the same as the original number<\/p>\r\n\r\n\r\n\r\n<p>\u00a08. When yes, the number is labelled an Armstrong number<\/p>\r\n\r\n\r\n\r\n<h2 id=\"Python-program-to-check-Armstrong-Number:\" class=\"has-vivid-cyan-blue-color has-text-color\"><strong>5) Python program to check Armstrong Number:<\/strong><\/h2>\r\n\r\n\r\n\r\n<p>Now use Python to understand\u00a0what is Armstrong number\u00a0by implementing the above algorithm in Python as below to understand\u00a0what is Armstrong number in python.<\/p>\r\n\r\n\r\n\r\n<p>num= int(input(&#8216;Enter a number: &#8216;))<\/p>\r\n\r\n\r\n\r\n<p>num_original =num2=num<\/p>\r\n\r\n\r\n\r\n<p>sum1 = 0<\/p>\r\n\r\n\r\n\r\n<p>cnt=0<\/p>\r\n\r\n\r\n\r\n<p>while(num&gt;0):<\/p>\r\n\r\n\r\n\r\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 cnt=cnt 1<\/p>\r\n\r\n\r\n\r\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 num=num\/\/10<\/p>\r\n\r\n\r\n\r\n<p>while num2&gt;0:<\/p>\r\n\r\n\r\n\r\n<p>\u00a0\u00a0\u00a0rem = num2% 10<\/p>\r\n\r\n\r\n\r\n<p>\u00a0\u00a0\u00a0sum1\u00a0 = rem ** cnt<\/p>\r\n\r\n\r\n\r\n<p>\u00a0\u00a0\u00a0num2\/\/= 10<\/p>\r\n\r\n\r\n\r\n<p>if(num_original==sum1):<\/p>\r\n\r\n\r\n\r\n<p>\u00a0\u00a0\u00a0\u00a0print(&#8216;Armstrong!!&#8217;)<\/p>\r\n\r\n\r\n\r\n<p>else:<\/p>\r\n\r\n\r\n\r\n<p>\u00a0\u00a0\u00a0\u00a0print(&#8216;Not Armstrong!&#8217;)<\/p>\r\n\r\n\r\n\r\n<p>Output<\/p>\r\n\r\n\r\n\r\n<p>\u00a0Now in the field \u2018Enter a number, enter the\u00a0Armstrong number in python\u00a0or number: 153. The output shows\u00a0Armstrong number Python\u00a0\u2018Armstrong\u2019.<\/p>\r\n\r\n\r\n\r\n<p>\u00a0Next try the algorithm with the field \u2018Enter a number as 134 or Enter a number: 134. The output this time is, Not Armstrong!<\/p>\r\n\r\n\r\n\r\n<p>To test the code: Remember<strong>\u00a0<\/strong>num stores the number of digits in the input whereas num_original stores the initial value of the input.\u00a01 Armstrong is equal to\u00a0sum 1=0 and cnt=0. Using the variable num_2, one computes the sum of individual digits in the original number raised to the power of the count variable. Then compare the original number with the sum obtained to see if it exhibits properties in the\u00a0Armstrong number program in Python\u00a0to be an Armstrong number<\/p>\r\n<h2><span style=\"color: #3366ff;\"><b>6) Program To Find All The Armstrong Numbers Between 0 And 999<\/b><\/span><\/h2>\r\n<p><span style=\"font-weight: 400;\">This program generates an <\/span><b>Armstrong numbers list<\/b><span style=\"font-weight: 400;\"> between 0 and 999. An Armstrong number is one whose sum of digits raised to the power three equals the number itself. 371, for example, is an Armstrong number because 3**3 + 7**3 + 1**3 = 371.<\/span><\/p>\r\n<p>&nbsp;<\/p>\r\n<p><span style=\"font-weight: 400;\">PROGRAM\u00a0 ArmstrongNumber<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0IMPLICIT\u00a0 NONE<\/span><\/p>\r\n<p>&nbsp;<\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0INTEGER :: a, b, c \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u201c<\/span><i><span style=\"font-weight: 400;\">the three digits<\/span><\/i><span style=\"font-weight: 400;\">\u201d<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0INTEGER :: abc, a3b3c3 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u201c<\/span><i><span style=\"font-weight: 400;\">the number and its cubic sum<\/span><\/i><span style=\"font-weight: 400;\">\u201d<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0INTEGER :: Count \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u201c<\/span><i><span style=\"font-weight: 400;\">a counter<\/span><\/i><span style=\"font-weight: 400;\">\u201d<\/span><\/p>\r\n<p>&nbsp;<\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0Count = 0<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0DO a = 0, 9\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u201c<\/span><i><span style=\"font-weight: 400;\">for the left most digit\u201d<\/span><\/i><\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0DO b = 0, 9 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u201c<\/span><i><span style=\"font-weight: 400;\">for the middle digit<\/span><\/i><span style=\"font-weight: 400;\">\u201d<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0DO c = 0, 9 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u201c<\/span><i><span style=\"font-weight: 400;\">for the right most digit\u201d<\/span><\/i><\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0abc\u00a0 \u00a0 = a*100 + b*10 + c \u00a0 !\u00a0 \u00a0 \u00a0 \u00a0 \u201c<\/span><i><span style=\"font-weight: 400;\">the number<\/span><\/i><span style=\"font-weight: 400;\">\u201d<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0a3b3c3 = a**3 + b**3 + c**3 !\u00a0 \u00a0 \u00a0 \u00a0 \u201c<\/span><i><span style=\"font-weight: 400;\">the sum of cubes\u201d<\/span><\/i><\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0IF (abc == a3b3c3) THEN \u00a0 \u00a0 !\u00a0 \u00a0 \u00a0 \u00a0 \u201c<\/span><i><span style=\"font-weight: 400;\">if they are equal<\/span><\/i><span style=\"font-weight: 400;\">\u201d<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Count = Count + 1\u00a0 \u00a0 \u00a0 \u00a0 ! \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u201c<\/span><i><span style=\"font-weight: 400;\">count and display it<\/span><\/i><span style=\"font-weight: 400;\">\u201d<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0WRITE(*,*)\u00a0 &#8216;Armstrong number &#8216;, Count, &#8216;: &#8216;, abc<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0END IF<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0END DO<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0END DO<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0END DO<\/span><\/p>\r\n<p>&nbsp;<\/p>\r\n<p><span style=\"font-weight: 400;\">END PROGRAM\u00a0 ArmstrongNumber<\/span><\/p>\r\n<p>&nbsp;<\/p>\r\n<h3><span style=\"font-weight: 400;\">Input and Output of the above program<\/span><\/h3>\r\n<p>&nbsp;<\/p>\r\n<p><span style=\"font-weight: 400;\">The output of the preceding program is shown below. There are six Armstrong numbers between 0 and 999.<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">Armstrong number 1: 0<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">Armstrong number 2: 1<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">Armstrong number 3: 153<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">Armstrong number 4: 370<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">Armstrong number 5: 371<\/span><\/p>\r\n<p><span style=\"font-weight: 400;\">Armstrong number 6: 407<\/span><\/p>\r\n\r\n\r\n\r\n<h2><strong>Conclusion<\/strong><\/h2>\r\n\r\n\r\n\r\n<p>One can study\u00a0what is Armstrong number,\u00a0its\u00a0implementation and its algorithm in Python here.\u00a0So, are there any practical applications using the unique property of Armstrong numbers? In reality, there are none and the uniqueness of these numbers hold no practical use except as examples or learning tools to verify programs, learn concepts better and explore the rules in a new programming language.<\/p>\r\n\r\n\r\n\r\n<p>If you are interested in making a career in the Data Science domain, our 11-month in-person\u00a0<strong><a href=\"https:\/\/www.jigsawacademy.com\/post-graduate-diploma-in-data-science-pgds-certification-training\/\">Postgraduate Certificate Diploma in Data Science<\/a>\u00a0<\/strong>course can help you immensely in becoming a successful Data Science professional.\u00a0<\/p>\r\n\r\n\r\n\r\n<h2>ALSO READ<\/h2>\r\n\r\n\r\n\r\n<ul>\r\n<li><strong><a href=\"https:\/\/www.jigsawacademy.com\/blogs\/data-science\/rdbms\/\">RDBMS \u2013 A Comprehensive Guide (2021)<\/a><\/strong><\/li>\r\n<\/ul>\r\n","protected":false},"excerpt":{"rendered":"<p>Introduction What is Armstrong Number? Armstrong Number Logic Armstrong number examples Armstrong Number Algorithm Python program to check Armstrong Number Program To Find All The Armstrong Numbers Between 0 And 999 1) What is Armstrong Number? Beginners often wonder\u00a0what is Armstrong number\u00a0aka the narcissist number. It is of special interest to new programmers and those [&hellip;]<\/p>\n","protected":false},"author":122,"featured_media":253169,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[659],"tags":[6452,6451,6455,6454,6457,6453,6458,6456,6450],"form":[10311],"acf":[],"_links":{"self":[{"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/posts\/173223"}],"collection":[{"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/users\/122"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/comments?post=173223"}],"version-history":[{"count":13,"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/posts\/173223\/revisions"}],"predecessor-version":[{"id":253170,"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/posts\/173223\/revisions\/253170"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/media\/253169"}],"wp:attachment":[{"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/media?parent=173223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/categories?post=173223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/tags?post=173223"},{"taxonomy":"form","embeddable":true,"href":"https:\/\/www.jigsawacademy.com\/wp-json\/wp\/v2\/form?post=173223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}