Thumbnail source:
By Theo van Doesburg - kemperartmuseum.wustl.edu: Public Domain, https://commons.wikimedia.org/w/index...
I assume there are faster ways than mine, but with my level of math and coding, I think that these 2 shortcuts are simple and intuitive enough. Obviously not suitable for generating big primes used in cryptography.