tubeshowcase●1,070,233 videos♡ My collection 0
← Science

Science18:37

How on Earth does ^.?$|^(..+?)\1+$ produce primes?

Stand-up Maths ↗

From the creator

Take your personal data back with Incogni! Use code standupmaths at the link below and get 60% off an annual plan: https://incogni.com/standupmaths ^.?$|^(..+?)\1+$ Props will be for sale here: https://www.ebay.co.uk/usr/standupmaths Fantastic blog post by Illya Gerasymchuk. "Demystifying The Regular Expression That Checks If A Number Is Prime" https://illya.sh/the-codeumentary-blog/regular-expression-check-if-number-is-prime/ Thanks to everyone who has sent in history about this regex. Seems it was written ≥25 years ago by a Perl programmer named Abigail. Cheers to viewer Dave Cross who found this earliest-known mention in a 2000 blog post: http://test.neilk.net/blog/2000/06/01/abigails-regex-to-test-for-prime-numbers/ Thanks to viewers Chris Lawrence and Jimmy Diep for suggesting the topic. Huge thanks to my Patreon supporters. They keep me supplied with all the primes I need. https://www.patreon.com/standupmaths CORRECTIONS - Several people have corrected me that regex is zero indexed it’s just that \0 refers to the entire matched string. - Mike Salisbury ands others have pointed out that the left-most column in the table of repeated wild cards shouldn't be included. Otherwise the length of the string could match a single prime length. - At 6:07 I say "Begins and end with an m" when I meant ends with an “s”. No one has corrected that mistake with more vigour than viewer Timur Sultanov. - There is some concern about my pronunciation of rejex. - Let me know if you s

Published 2024-10-31 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.

Keep exploring Science