I have just created a Java version:
import java.util.Vector;
public class ArmstrongNumbers {
Vector<Integer> numbers = new Vector<Integer>();
public ArmstrongNumbers(int from, int to) {
for (int i=from; i<to; i++) {
if (isArmstrongNumbers(i)) {
numbers.add(i);
}
}
}
public static boolean isArmstrongNumbers(int number) {
int len = (""+number).length();
int workingNumber = number;
int sum = 0;
for (int i=0; i<len; i++) {
sum += Math.pow(workingNumber%10, len);
workingNumber /= 10;
}
return sum == number;
}
public String toString() {
return numbers.toString();
}
public static void main(String[] args) {
System.out.println(new ArmstrongNumbers(1, 10000000));
}
}