The instructions are:
An interesting problem in number theory is sometimes called the "necklace problem." This problem begins with two single-digit numbers. The next number is obtained by adding the first two numbers together and saving only the ones-digit. This process is repeated until the "necklace" closes by returning to the original two numbers. For example, if the starting numbers are 1 and 8, twelve steps are required to close the "necklace":
1 8 9 7 6 3 9 2 1 3 4 7 1 8
Here's another program:
It says to...
modify the program to determine what integers of two, three, or four digits are equal to the sum of the cubes of their digits
Here's the code:
CODE
/* Chapter 4 Exercise 9 by Albert Villaroman 11-20-06 */
#include <iostream.h>
int main() {
long numValue; //user input
cout <<"Enter an integer: ";
cin >>numValue;
long MaxDigits = 100000000;
while (MaxDigits > numValue) { //while loop to get how many digits numValue has
MaxDigits /= 10;
}
long sum = 0; //sum of all digits
while (MaxDigits >=1) {
long digit = numValue / MaxDigits; //get digit
sum += digit*digit*digit;
numValue = numValue % MaxDigits; //enter new value for numValue
MaxDigits /= 10; //ex: 100 => 10
}
cout <<"Sum of the cubes of the digits is " <<sum <<endl;
return(0);
}

