Hi!

I wrote a program on iteration of numbers means--

if n=10 ---n=10/2=5 5 is odd so 3(n)+1 upto getting 1.

Here is program

```
#include<stdio.h>
main()
{
int i,n,c=0;
printf("n= ");
scanf("%d",n);
while(n!=1){
if(n%2==0){
n=n/2;
}
else{
n=3*n+1;
}
printf("%d\t",n);
c++;
printf("%d\n",c);/*printing no of iterations of n*/
}
}
```

I wanted to change this program so as to do this upto a number 10 or x

I have tried using for loop but it doesn't work

`for(n=1;n<=10;++n)`

Please help me writing it .Any help would be appreciated..Thanks

Sorry If my post is posted bad..

If you don't undrstand please see this question

Start with a positive integer n. If n is even, divide it by 2, else replace n by 3n+1. Repeat until we obtain the value 1 in the sequence. The 3x+1 conjecture says that we eventually reach 1 irrespective of what initial value of n we start with.

Different initial values of n lead to different numbers of iterations of the loop before hitting the value 1. For example, if we start with n=3, we get a sequence 3,10,5,16,8,4,2,1 using 7 iterations. If we start with 7, we need 16 iterations, since the sequence is now 7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1.

You are given a bound B. Your task is to locate that particular value of n in the range 1<=n<=B for which the number of iterations is maximum. Once this integer nis located, you print n, the corresponding number of iterations, and finally the sequence associated with n.

If the bound is 10, then the output of your program would look like:

Maximum number of iterations = 19 for n = 9.

The sequence is:

9 28 14 7 22 11 34 17

52 26 13 40 20 10 5 16

8 4 2 1

Report the output of your program for the bound 100,000.