Necklace Problem Help
807589Nov 12 2008 — edited Nov 12 2008Hey guys, I'm a beginner programmer (so don't assume that I would know anything) and I'm having trouble with this necklace problem. Some of you probably know what it is, but I'll post it anyway:
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, the output would look like:
18976392134718
Can anyone post the basic code for this, because I am just getting into iteration and this is all sort of confusing for me. I know what to do to solve the problem mathematically, but the variables are really tricky because you have to assign new values to existing variables. Also, I'm pretty sure a do-while loop will work here, but I do not know the specifics. Please, any help would be greatly appreciated.