Collatz conjecture: Difference between revisions

From Rosetta Code
Content added Content deleted
(Start removing this page. Delete all languages that already have sections at Hailstone sequence.)
(Remove draft task. Add #REDIRECT Hailstone sequence)
 
Line 1: Line 1:
#REDIRECT [[Hailstone sequence]]
{{alertbox|#ffe4e4|'''Rosetta Code is removing this draft task in favour of [[Hailstone sequence]]. DO NOT add to this page as it is going away. '''}}
{{draft task}}
These programs calculate the [[wp:Collatz conjecture|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.

=={{header|Befunge}}==
<lang befunge>&>:.:1-|
>3*^ @
|%2: <
v>2/>+</lang>

=={{header|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

=={{header|Ioke}}==
<lang ioke>collatz = method(n,
n println
unless(n <= 1,
if(n even?, collatz(n / 2), collatz(n * 3 + 1)))
)</lang>

Latest revision as of 21:49, 13 November 2011

Redirect to: