the task is as following: "The following iterative sequence is defined for the set of positive integers:

n → n/2 (n is even)

n → 3n + 1 (n is odd)

Using the rule above and starting with 13, we generate the following sequence:

13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1

It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it has not been proved yet (Collatz Problem), it is thought that all starting numbers finish at 1.

Which starting number, under one million, produces the longest chain?"

I try with the following:

laps=1 counter = 1 topnumber = 0 sequencelength=0 nextnumber = 0 def next(number) if(number%2 == 0) counter+=1 nextnumber =(number/2) return true end if number==1 return false end if(number%2!=0) counter+=1 nextnumber =(3*number+1) return true end end while laps < 1000001 nextnumber=laps while(next(nextnumber)) end if (counter > sequencelength) sequencelength = counter topnumber=laps counter = 1 laps+=1 end puts topnumber

I get 3 errors.

Line 26 and 28 gives "void value expression"

Line 34 gives "syntar error unexpected $end, nexpecting kEND"

How can I correct my errors, and is my idea even worth anything? thanks.

edit: just noticed a whole lot of things that are wrong.

This post has been edited by **wellwell**: 12 July 2011 - 04:34 PM