|
3x+1 problem
|
|
08-02-2009, 10:38 PM
Post: #1
|
|||
|
|||
|
3x+1 problem
I was looking through some of problems that i used to solve few years ago, and i came across an simple problem !
Consider the following algorithm to generate a sequence of numbers. Start with an integer n. If n is even, divide by 2. If n is odd, multiply by 3 and add 1. Repeat this process with the new value of n, terminating when n = 1. For example, the following sequence of numbers will be generated for n = 22: Code: 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1This is solution is TPW : Code: program three_x_plus_one;Code: # include <iostream>There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
« Next Oldest | Next Newest »
|





