{"id":19001,"date":"2021-08-29T15:13:12","date_gmt":"2021-08-29T09:43:12","guid":{"rendered":"https:\/\/python-programs.com\/?p=19001"},"modified":"2021-11-22T18:37:09","modified_gmt":"2021-11-22T13:07:09","slug":"python-program-to-find-the-previous-armstrong-number","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-the-previous-armstrong-number\/","title":{"rendered":"Python Program to Find the Previous Armstrong Number"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Find the Next Armstrong Number<\/a>
\nArmstrong Number:<\/strong><\/p>\n

Beginners sometimes ask what the Armstrong number, also known as the narcissist number, is. Because of the way the number behaves in a given number base, it is particularly interesting to new programmers and those learning a new programming language. The Armstrong number meaning in numerical number theory is the number in any given number base that forms the sum of the same number when each of its digits is raised to the power of the number\u2019s digits.<\/p>\n

Itertools count() function:<\/strong><\/p>\n

The count(start, step) method generates an iterator that is used to generate equally spaced numbers, where the step argument defines the space between them. The start argument specifies the iterator’s starting value, which is set by default to start=0 and step=1.<\/p>\n

In the absence of a breaking condition, the count() method will continue counting indefinitely (on a system with infinite memory)<\/p>\n

Given a number, the task is to print the previous Armstrong number in Python.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number =67<\/pre>\n

Output:<\/strong><\/p>\n

The previous armstrong number of { 67 } is : 9<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number =450<\/pre>\n

Output:<\/strong><\/p>\n

The previous armstrong number of { 450 } is : 407<\/pre>\n

Program to Find the Previous Armstrong Number in Python<\/h2>\n

Below are the ways to find the previous Armstrong number in Python:<\/p>\n