My assignment is to print all the happy numbers from 10 until the program prints 3 consecutive numbers. Those 3 numbers should be 1880 1881 and 1882. i wrote while(num2<1883) just for the loop to stop. i should compare the 3 last "sums" and stop the loop when they are consecutive.
do {
num = num2;
while (num > 0 || sum > 9) {
if (num == 0) {
num = sum;
sum = 0;
}
sum += Math.pow(num % 10, 2);
num /= 10;
}
if (sum == 1) {
counter++;
System.out.println(counter + ") " + num2 + " is a happy number :-)");
}
num2++;
sum = 0;
} while (num2 < 1883);//<---?????