Prime number checker

This board is to show, discuss and archive useful combinator- and logic-creations.
Smart triggering, counters and sensors, useful circuitry, switching as an art :), computers.
Please provide if possible always a blueprint of your creation.
Post Reply
ArcusVonSinus
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sun Jan 14, 2018 9:45 pm
Contact:

Prime number checker

Post by ArcusVonSinus »

I made a circuit computer, which determines if the number of all items in a chest is a prime number, then it will light up green. Otherwise it will light up red. The power pole is just to indicate where is the index which goes from 2 to the number of items (the largest among all sorts of them).

Image

https://factorioprints.com/view/-L2qdWZACpEIgd6i-7Ex

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3699
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Prime number checker

Post by DaveMcW »

Here is a smaller and faster version, using the new "modulo Each" operator. It works for up to 160,000 items.



prime.jpg
prime.jpg (84.07 KiB) Viewed 1340 times
Last edited by DaveMcW on Fri Mar 26, 2021 11:33 am, edited 1 time in total.

ArcusVonSinus
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sun Jan 14, 2018 9:45 pm
Contact:

Re: Prime number checker

Post by ArcusVonSinus »

Nice!
Mine works itemwise, it checks if there is a prime amount of every item. But it is much slower :-)

Post Reply

Return to “Combinator Creations”