id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

andersoniii.edwin@cusd80.com > necklace
prev  |  next  |  chance

Necklace - An interesting problem in number theory called the "necklace 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 from the sum. This new digit and the one previous digit are then added and again keeping only the ones-digit from the sum. This process is repeated until the "necklace" closes to the two original 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 == 12 numbers


necklace(0, 8) → 20
necklace(0, 0) → 1
necklace(1, 3) → 12

...Save, Compile, Run (ctrl-enter)

public int necklace(int first, int second) }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 125

Copyright Nick Parlante 2017 - privacy