This reminds me of my favorite in-person magic trick to do. First, memorize all the two-digit primes. 25 numbers isn't that hard to memorize. Then, tell someone "Oh, I can instantly tell whether a number is prime or not. Give me a number, I'll tell you whether it's prime." If they tell you a number between 1 and 100, use your memorized list. Otherwise, it's a game of cold reading; if they just generated a random stri…
Is This Prime?
131–139 of 139 posts
Re: Is This Prime?
#132 def is_prime(n):
return not True in [n%x == 0 for x in range(2, n/2)]Re: Is This Prime?
#133I am not doing _that_ type of number crunching in my daily work, so the following check (in Python) has probably lots of potential for improvement: def is_prime(n): return not True in [n%x == 0 for x in range(2, n/2)]
even better you only need to test the primes <= floor(sqrt(n))
Re: Is This Prime?
#134Re: Is This Prime?
#135Earlier quoted context omitted.
We memorized pi to 7 decimal places... a few memorized it to 20+
Now I, even I, would celebrate In rhymes unapt, the great Immortal Syracusan, rivalled (sic) nevermore Who, in his wondrous lore, Passed on before, Left men his guidance How to circles mensurate.
Re: Is This Prime?
#136Earlier quoted context omitted.
I agree. And I would add 51 to that.
They have stats on the most common mistakes here: https://isthisprime.com/game/record.php (loads very slowly) 51 is #1, then 57, then 1
Re: Is This Prime?
#137Earlier quoted context omitted.
No, at the cryptographic scale of prime numbers the lookup table would need to be far too big in terms of both time to generate and storage required. For smaller numbers see various prime sieves (Atkin, Eratosthenes)
Time to generate I get, but you could always augment the table over time and fall back to standard methods otherwise (and store the result). Storage I have a harder time wrapping my head around. Aren’t primes quite sparse at cryptographic magnitudes? And are the primes used for (say) 256-bit encryption about the same magnitude, narrowing the dimension of storage required?
Re: Is This Prime?
#138Earlier quoted context omitted.
Time to generate I get, but you could always augment the table over time and fall back to standard methods otherwise (and store the result). Storage I have a harder time wrapping my head around. Aren’t primes quite sparse at cryptographic magnitudes? And are the primes used for (say) 256-bit encryption about the same magnitude, narrowing the dimension of storage required?
The primes are quite dense. There are roughly n/log(n) primes below n. Meaning 1 in 256 numbers with 256 bits are prime. That's 2^(248) primes. For RSA one typically use 2048 or 4096 bit primes.