Collatz conjecture

From Rosetta Code
Revision as of 21:41, 13 November 2011 by rosettacode>Kernigh (Start removing this page. Delete all languages that already have sections at Hailstone sequence.)
Rosetta Code is removing this draft task in favour of Hailstone sequence. DO NOT add to this page as it is going away.
Collatz conjecture is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

These programs calculate the Collatz sequence for a given integer, and stop if 1 is reached.

These programs were written before this task was created; as such, the specific actual requirements of this task have not yet been determined.

Befunge

<lang befunge>&>:.:1-|

 >3*^ @
 |%2: <
v>2/>+</lang>

Excel

   In cell A1, place the starting number.
   In cell A2 enter this formula =IF(A1/2=ROUND(A1/2,0),A1/2,A1*3+1)
   Drag and copy the formula down until 4, 2, 1

Ioke

<lang ioke>collatz = method(n,

 n println
 unless(n <= 1,
   if(n even?, collatz(n / 2), collatz(n * 3 + 1)))

)</lang>