For the sake of practice I created a node that can check if a number is a prime number and find prime numbers from a list. If I’m honest I’m not exactly expecting it to be ever useful in a regular Dynamo script, but I thought I’d share it anyway.
You can give a number or list of numbers as an input. And it will give you a list of the numbers from the input that are prime and simply give a boolean on whether a number is prime or not.
CheckPrime.DYF (21.0 KB)
Credit where credit is due: I did use Clockwork’s
heres a python method for calculating primes that you may enjoy
it takes all the numbers between 2 and 102 and removes the numbers that are not prime
I wanted to inform you:
I moved the thread to the category Share.
I’m no Python expert, but I’m guessing this is using a modulo. As is my node.
To keep my node somewhat efficient and being able to check for really big numbers (it should cover everything up to 62710561), it actually has the first 1000 prime numbers in there in the first place.
I had no idea where to actually put this topic.
I just gave it an update to fix something which might have caused quite a lot of issues.