The Odd ball Problem

In this problem, you are given N balls that look identical except that they are numbered
and one of them is a bit heavier or lighter than the others. The only way to find this odd ball
is do a series of weighings on a balance scale.

The goal is to perform the minimum number of weighings possible. Typically the problem is posed with N=12 and the goal
is to come up with a way that never takes more than 3 weighings.

I like this problem and have written about it earlier. As I said there, I do not know of another general solution,
but when N can expressed as (3^n-3)/2, there are very nice solutions herehere and here.

I was trying to learn Javascript and decided I'd come up with a program that solves this problem for any N. Please do try it out!
By the way the balls are numbered from 0 to N-1 in the program.


How many balls do we have?