Forums > MaxMSP

Gen function declaration

April 24, 2014 | 3:29 am

Hi,

I would like to ask a question to people who are familiar with gen.
I’m trying to implement a factorial function like this:

factorial(N) {
if (N <= 1) {
return 1;
}
result=2;
for (i=3; i <= N; i++) {
result=(i+alpha+1)*i;
}
return result;
}

However I get the "statement missing ;" in a first line.

Can you point me out whats wrong with this function. This example is from JavaScript book.

The Max version I use is 6.1.7 32 Bit on Windows 7.


April 24, 2014 | 7:28 am

Gen~ doesn’t have a ++ operator. You have to use something like i += 1.


April 24, 2014 | 10:27 pm

Thank you Emmanuel, I will look into this.


Viewing 3 posts - 1 through 3 (of 3 total)