Jun 29 2007 | 2:59 am

I have a prime factorization patch that seems to work fine up until prime number 239. I have no freaking clue why it generates a stack overflow at that point, all composite and prime numbers below that are totally fine. Prime numbers over 256 seem to crash Max even more thoroughly, which might make more sense, though I'm not using any objects with that limitation (zl, yes, but it's used to read the length of the prime factor list, nowhere ever near 256).

The subpatch with the factorization seems to be totally OK (though messy) and I can't figure out why it would overflow at this specific point. I figured (with enough numbers in the counter as possible prime factors) that any number would be OK to factor (with the counter range up to the square root of the main number).

Yes, I *do* have a javascript that factors any number just fine, but I wanted to try and figure it all out in Max. Maybe not the best idea as it's taken a long time, but it would be nice to understand what's causing the overflow if anyone has some ideas. Also wondering if others get the same overflow error at the same point (239).

There's a warning next to the overflow-causing number, so be careful. ;)

-CJ

-------------------------

max v2;