![]() |
VOOZH | about |
An Armstrong number (also known as a narcissistic number or pluperfect digital invariant) is a number that is equal to the sum of its own digits each raised to the power of the number of digits in the number. For example, a 3-digit Armstrong number would be equal to the sum of the cubes of its digits.
In R Programming Language there are some steps required to create a program for Armstrong number.
To check for an Armstrong number in R, follow these steps:
a. Take the input number from the user or use a predefined number.
b. Find the number of digits in the number.
c. Calculate the sum of each digit raised to the power of the number of digits.
d. Compare the sum with the original number to check if it is an Armstrong number.
e. Display the result.
Output:
153 is an Armstrong number.Output:
155 is not an Armstrong number.