When a test is contrapositive, it's actually testing for composites. So technically, it should output True for composite but then, the name isPrime doesn't do justice. So I changed the outputs to strings 'Prime' and 'Composite'.
That'd have roughly as many characters as a 338,000 word book... longer than The Brothers Karamazov (365,000) but shorter than Gone With The Wind (418,000).
Just over half the length of A Suitable Boy by Vikram Seth, and probably just as entertaining. Heyooo!
> There's no slick trick to check fast enough, whether or not a large number is prime. So much so that finding large prime numbers has been an obsession for mathematicians.
But that's still false; in fact, the rest of your article talks about the Fermat and Miller-Rabin primality test, which are indeed slick tricks that can check fast enough whether or not a large number is prime (to whatever degree of confidence you desire)!
Also, finding large prime numbers isn't really an obsession anymore -- you can use any of the fast primality test algorithms mentioned above, randomly generate numbers of a desired bit length, and stop when you hit a (probable) prime, which happens fairly quickly by the prime number theorem: https://en.wikipedia.org/wiki/Prime_number_theorem
You may be thinking of the search for Mersenne primes, or other primes of a specific form.
I thought modern RSA crypto intentionally stays away from real primes because it's less secure. They use two semi-prime co-primes of significant size and with a large enough difference between them.
A RSA private key uses large primes, two to be exact. Those two primes form your private key. Multiplying them together gives your public key. The idea is that undoing that operation: finding which two primes multiplied together form the public key, is an intractable problem.
Those two primes multiplied together is what's called a semiprime. The one part that you're correct on is that these two primes should be sufficiently distant, otherwise just trying a couple numbers near sqrt(pq) will give you either p or q.
"Itself" might be 1 in the first definition. The "exactly two" in the second definition is what makes the definitions different.
I'm not able to read the article because of a 503 timeout, so I can't see this in context, so the following might be irrelevant or off the mark (sorry).
A more interesting/usual pair of definitions is
1. A non-unit p is prime if whenever p divides ab then p divides a or p divides b.
2. A nonzero number n is composite if there are non-units a and b such that n = ab.
Then there is a short proof that, for nonzero non-units, being prime is equivalent to not being composite. (A unit is a number with a reciprocal in the number system. For the integers, that would be 1 and -1.)
The two definitions capture different (but equivalent) parts of the atomic nature of primes.
Elsewhere in mathematics, there are the concepts of irreducibility (whether an object has a subobject) and indecomposibility (whether an object splits into subobjects), where in general irreducible things are indecomposible. Basically, the fact that long division works implies that indecomposible numbers are irreducible and that irreducible factors don't straddle the decompositions.
Okay.. so 1 should neither be prime nor composite. Because -
a) 1 cannot be written as a product of two different factors : ruling out 1 to be composite
b) 1 has only 1 positive divisor : ruling it out to be prime
That's indeed a special case which can be mentioned in the article.
I would simply not define "prime" or "composite" for 1, yes. If you check abstract algebra books (or wikipedia [1]), you'll usually find definitions along the lines of "a non-invertible, non-zero element is prime if and only if ...", and the nice thing about this definition is that it is a useful concept in more general structures than just natural numbers, namely (semi)rings.
I'm one of the founders of the site. We're testing a different format which helps people learn easily about a new topic. The idea is to break down information around a topic into bite-sized, slide-like chapters making it less overwhelming and more effective compared to a lot of information dumped in a single page. We're working to make this more interactive in future, from a learner's point of view.
Enabling JS makes sure the slides work.
If you have any ideas related to navigation, i'd be happy to learn more.
The content for this particular article would work fine as a single page. The sections are small and bite-sized with clear headings and separations.
It's a bit discombobulating to paginate and scroll. The slide approach would work better if the contents were limited to a single page without vertical scroll (IMO). Feels a bit like a "mixed metaphor" in terms of design patterns.
yeah, makes sense. We're indeed trying to find ways so authors could keep the contents of a single slide contained within the users view. Hope we get to a design sweet spot soon.
I'm one of the founders of the site. Thanks for explicitly mentioning this.
We're testing a new format which helps people learn easily about a new topic. The idea is to break down information around a topic into bite-sized, slide-like chapters making it less overwhelming and more effective compared to a lot of information dumped in a single page. We're working to make this more interactive in future, from a learner's point of view.
Albeit we're still getting more feedback on it - yours being one of them. If you have any ideas related to improving navigation, i'd be happy to learn more.
Also, it'n not intended to get more clicks nor it generates anymore page views than 1 per user visit (no matter how much you go back and fourth within a single guide).
Totally! Ryan is very aggressive at doing this. But the way he came up with a way to build an MVP (via his email list) in 20 minutes before spending weeks to build something is really clever.