On Tuesday, July 9, 2019 at 8:09:04 AM UTC-4, Bob Heffernan wrote: > > Dear all, > > I recently wanted to count the number of primes in the sequences 2^n+3 > and 2^n-3 (and a few more besides) where n is a positive integer. > > <SNIP>
Hi Bob. This has nothing to do with Racket, and you may already know it, so I will just hint. If p is prime, the sequence a^n + b (mod p) is periodic with period (p-1). Divisibility by p depends only on [ n mod (p-1) ]. A fast test can eliminate n for which a^n + b is divisible by p. Do this for 3 and 5. Check out "Fermat's little theorem" for the general case. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/b258ab0a-ed7d-4af0-aea9-6f559a4aadf7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.