s <- 99:1000000

armstrong <- vapply(s, function(x) {

tmp <- strsplit(as.character(x), split="")

exponent <- length(tmp[[1]])

sum <- sapply(tmp, function(y)sum(as.numeric(y)^exponent))

return(sum == x)
},FUN.VALUE = 1)

s[armstrong == 1]