can anyone p/z help me with this i am suppose to create a program that investigates conjecture. the question is as follows. Investigate the sequence of numbers produced when a number is halved if even, or multiplied by 3 and then increased by 1 if the number is odd.

Example:
Take 7 as the starting point. Then
7 = 7 x 3 + 1 = 22
22 = 22/2 = 11
11 = 11 x 3 + 1 = 34
34 = 34/2 = 17
. . .
Continue the above sequence until it reaches 1 and then investigate the process with other starting points:'(

sounds like your app is going to be using a lot of loops. not too hard, i wont do your homework. post up some of your code and what you think it should do and we will go from there.

a good starting point

method 1:

Y = starting point
N = new number

determin if number is even or odd (simple division can tell you this)

if EVEN
N = Y / 2
ELSE IF ODD
N = Y * 3 + 1

repeat loop

You need only one loop and the use of the modulus operator.

``````private void btnGo_Click(object sender, EventArgs e)
{

txtresult.Clear(); // TextBox to display results (multiline)
int result = Convert.ToInt32( txtNum.Text ); // textbox to hold value to examine
while (result != 1)
{
if (result % 2 == 0) // it is even
{
result = result / 2;
}
else // it is odd
{
result = result * 3 + 1;
}
// Display Results
txtresult.Text = txtresult.Text + result.ToString() + System.Environment.NewLine;
}
MessageBox.Show("Completed");
}``````
commented: we dont do peoples homework here. -1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.