vendredi 16 septembre 2016

Programming necklaces in java

Could someone help me with this please (in java)? Given two single-digit numbers. The next number is obtained by adding the first two numbers together modulo 10. This process is repeated until returning to the original two numbers. For example, if the starting numbers are 1 and 8, 12 steps are required to close the “necklace”: 1 8 9 7 6 3 9 2 1 3 4 7 1 8

Write a program that asks the user for two starting numbers, and then displays the sequence and the number of steps taken. The program output should look similar to:

 Enter the first number: 1
 Enter the second number: 8
 1 8 9 7 6 3 9 2 1 3 4 7 1 8
 Your number required 12 steps.

Aucun commentaire:

Enregistrer un commentaire