Is there an objetc that sends out 0 or 1 wether input is odd or prime?
Do you mean odd or even?
odd/even is dead easy: mask low order bit is one way, or do an integer divide by two and multiply back to see if you get the same number. Tim’s presumably using one of these (haven’t looked at his patch yet).
Prime isn’t quite so easy, but there are a couple of objects to help. If you check out MaxObjects.com (try < http://www.maxobjects.com/?request=prime>) you’ll find some objects that ought to suit your purposes. You may need to patch a bit around them to get what you need.
Never mind, my answer is the same as the patch above:
[% 2] gives 0 for odd, 1 for even numbers.
Yeah, modulo is in my post. Here’s a pointless way of doing it manually because I’m bored :)
expr (((($i1+1)/2)*2)-$i1) – pretty much what Peter said
found this .js on the forum, can’t recall who. brute-force way of determining primes (spits out factors), still plenty fast:
if (v>1) outlet(0,v);
Log in to reply
C74 IN YOUR INBOX
C74 RSS Feed | © Copyright Cycling '74 | Terms & Conditions
Let us tell you about notable Max projects, obscure facts, and creative media artists of all kinds.