How to check if a number is an armstrong number or not? Can anyone give the code to check armstrong number?

Sep 27, 2019 105 views

## 1 answer to this question.

Hey,

```# take input from the user
num = as.integer(readline(prompt="Enter a number: "))
# initialize sum
sum = 0
# find the sum of the cube of each digit
temp = num
while(temp > 0) {
digit = temp %% 10
sum = sum + (digit ^ 3)
temp = floor(temp / 10)
}
# display the result
if(num == sum) {
print(paste(num, "is an Armstrong number"))
} else {
print(paste(num, "is not an Armstrong number"))
}```

Source: datamentor

answered Sep 30, 2019 by anonymous
• 32,930 points

## Function to check if matrix empty or not

here is some question of what is ...READ MORE

## Check if the object(variable) is defined in R

You can use the exists(): > exists("toFindUnknown") [1] FALSE > ...READ MORE

+1 vote

## How to check if object is defines in R?

You can use the exists function for ...READ MORE

## Check if a matrix is diagonalizable in R Programming Language

On a given matrix, a, the first way ...READ MORE

## By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

## How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

## In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

## How to create a list of Data frames?

Basically all we have to do is ...READ MORE