Also, borrowed from http://rosettacode.org/wiki/Hailstone_sequence#J

hailseq=: -:`(1 3&p.)@.(2&|) ^:(1 ~: ]) ^:a:"0

Examples:

   hailseq 4
4 2 1
   hailseq 5
5 16 8 4 2 1

This is similar to the collatz^:a: mentioned in the wiki page.

-- 
Raul

On Thu, Oct 25, 2012 at 5:44 AM, Brian Schott <schott.br...@gmail.com> wrote:
> http://www.jsoftware.com/jwiki/Essays/Collatz%20Conjecture
>
> On Thu, Oct 25, 2012 at 5:12 AM, Stefan Stankovic
> <anonimnist...@gmail.com> wrote:
>> I have just started learning J and I think the language is wonderful. It is
>> breathtaking.
>>
>> I have a question about a basic thing-how can I create a monad (preferably
>> tacit) which will, given input x,provide a list of numbers which contains
>> the Collatz seqyence for the given x? Thanks in advance.
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to