{"id":1360,"date":"2022-03-03T07:29:01","date_gmt":"2022-03-03T07:29:01","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=1360"},"modified":"2022-03-03T07:29:01","modified_gmt":"2022-03-03T07:29:01","slug":"display-armstrong-number-b-w-two-intervals","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/03\/03\/display-armstrong-number-b-w-two-intervals\/","title":{"rendered":"Display Armstrong Number B\/w Two Intervals"},"content":{"rendered":"\n<p>A positive integer is called an Armstrong number of order&nbsp;<var>n<\/var>&nbsp;if<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">abcd... = a<sup>n<\/sup> + b<sup>n<\/sup> + c<sup>n<\/sup> + d<sup>n<\/sup> + ...<\/pre>\n\n\n\n<p>In case of an Armstrong number of 3 digits, the sum of cubes of each digit is equal to the number itself. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>153 = 1*1*1 + 5*5*5 + 3*3*3  \/\/ 153 is an Armstrong number.\n<\/code><\/pre>\n\n\n\n<p>This program is built on the concept of\u00a0how to check whether an integer is an Armstrong number or not.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Armstrong Numbers Between Two Integers<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>class Main {\n  public static void main(String&#91;] args) {\n\n    int low = 999, high = 99999;\n\n    for(int number = low + 1; number &lt; high; ++number) {\n      int digits = 0;\n      int result = 0;\n      int originalNumber = number;\n\n      \/\/ number of digits calculation\n      while (originalNumber != 0) {\n        originalNumber \/= 10;\n        ++digits;\n      }\n\n      originalNumber = number;\n\n      \/\/ result contains sum of nth power of its digits\n      while (originalNumber != 0) {\n        int remainder = originalNumber % 10;\n        result += Math.pow(remainder, digits);\n        originalNumber \/= 10;\n      }\n\n      if (result == number) {\n        System.out.print(number + \" \");\n      }\n    }\n  }\n}<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><samp>1634 8208 9474 54748 92727 93084 <\/samp><\/pre>\n\n\n\n<p>In the above program, each number between the given interval high and low is checked.<\/p>\n\n\n\n<p>After each check, the number of&nbsp;<var>digits<\/var>&nbsp;and the sum&nbsp;<var>result<\/var>&nbsp;is restored to 0.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A positive integer is called an Armstrong number of order&nbsp;n&nbsp;if abcd&#8230; = an + bn + cn + dn + &#8230; In case of an Armstrong number of 3 digits, the sum of cubes of each digit is equal to the number itself. For example: This program is built on the concept of\u00a0how to check [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[490],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1360"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=1360"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1360\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=1360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=1360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=1360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}