Jumping Number sequence

Nov 18, 2011 at 11:14pm

I need help with a program. I need to determine for a given element in the sequence the number of steps necessary for the element to become the leading element of the sequence.

input The program should accept an integer value representing the number that should become the leading element. the program should contuine to prompt for integers and output the results until an entry of zero terminates the problem.

output the form should be xxx becomes the leading element after xxx steps.
Last edited on Nov 18, 2011 at 11:16pm
Nov 19, 2011 at 12:33am
I am pretty bad at math and Im not sure what you want to accomplish but this should help you out a little. This code will read in an int and tell you how far the first digit is away from the end of the number.

There are definitely better ways to do this but I am not experienced enough to think them.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
using namespace std;

int main () {
	string g;
	int count; 

	cout << "Enter a num\n";
	cin >> g;
	
	count = g.size() - 1;   // length of number - 1 
                             
	cout << g[0] << " is " << count << " digits from the right";

return 0;
Last edited on Nov 19, 2011 at 12:43am
Nov 19, 2011 at 1:36am
What do you mean by "leading element" and "jumping number"?
Are you talking about number rings?
Topic archived. No new replies allowed.