@Naresh: The sequence of numbers generated by this rule for any given
starting number is called a Collatz Sequence. Try googling it.

Here is a list of the number of iterations required for n between 1
and 10,000: http://oeis.org/A006577/b006577.txt. Maybe that will help.

Dave

On Dec 11, 7:20 am, Naresh A <suryanar...@gmail.com> wrote:
> Given range of numbers between A and B (A<= B)
> Find the number within given range which has more number of iterations as
> per the following
>
>      n { stop ; return iteration number }  if n=1;
>      n = 3n+1                              if n is odd
>      n =  n/2                              if n is even
>
> for eg :
>
> n=3 odd
> ----
> n=10;
> n=5;
> n=16;
> n=8;
> n=4;
> n=2;
> n=1;
>
> iterations : 7
>
> --
> *
> Time complexity= (<n^2)
>
> *************************************************************
> *NARESH ,A*
> **

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to