How do you check if a number is prime?

Edit: I just want to make a block untitled script pic (58) that checks, as quickly as possible, if the number is prime.

Loop from $$2$$ to $$\lfloor \sqrt{n} \rfloor$$ (floor of the square root of n, the number if that's not cleaer) and check whether or not $$n$$ is divisible by that number. If it's not divisible by any number in that range then it's prime

Let's say. Each prime number (n) when I divide n by 2 I will have after the decimal point 3333 or 66666666667 and so on.


Where n₂ is a integer

But I don't know this always works right :-/


19:3= 6, 3333 ≈ 6,33
67:3 = 22,3333 ≈ 22,33
97:3 = 32,33333 ≈ 32,333
5:3 ≈ 1,67

Counterargument: 1 isn't prime but 1/3 = 0.333333333333333...
Counterargument 2: 25 isn't prime but 25/3 = 8 1/3 = 8.333333333333333...

Unfortunately :-/

I made a detector of prime numbers. Check- maybe work right...

That will never give a false negative, i.e., if it says the number isn't prime, then the number isn't prime, but it'll give a lot of false positives:

Interestingly enough, those numbers seem to follow +3 then +4 then +3 then +4 etc.

Somehow implement the sieve of Eratosthene. [ O(log(log(n)) vs O(n) ] Sieve of Eratosthenes - Wikipedia

This is the answer, you guys.

Earlier it worked good.

Edit: Now should work right. I forgot the ≥ character and unnecessarily I add a a-2

Already exists:
Screenshot 2022-01-26 09.03.23

Well where's the library?

It’s not a library. I believe that screenshot is from the help menu of the numbers from block.

Yes, but you said

implying there was a primitive or library with it.

Oh. No, I just meant that there was code for one.