Ads skipped

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

531K views · Oct 31, 2024 · Entertainment

Comments · 2.3K

  • @standupmaths · 1 year ago · pinned

    Take your personal data back with Incogni! Use code standupmaths at the link below and get 60% off an annual plan: <a href="https://incogni.com/standupmaths">https://incogni.com/standupmaths</a><br><br>Don’t use code ^.?$|^(..+?)\1+$.

    527

  • @Graphene_314 · 1 year ago

    The plural of regex is regrets.

    4.6K

  • @Yogarine · 1 year ago (edited)

    Regular expressions are already scary by nature. Making one that produces primes is truly terrifying.

    3.8K

  • @Cmanorange · 1 year ago

    wow, what a neat trick! i&apos;m adding this to my production code immediately, good luck new hires!

    4.1K

  • @scottieapplseed · 1 year ago

    I loved the home joke at the end; you&apos;re such a good localhost.

    284

  • @RMDragon3 · 1 year ago (edited)

    To simplify, this takes the number and expresses it as a unary numeral system, where the number of marks is the value of the number you put in (e.g. 1 is 1, 2 is 11, 3 is 111, ...). The regex then looks to divide the unary representation into exactly N groups of size M, where both N and M are natural numbers with value 2 or larger. For example, you can divide 4 (represented as 1111) into 2 groups of &quot;11&quot;. You can divide 6 (represented 111111) into 2 groups of &quot;111&quot; or 3 groups of &quot;11&quot;. However, you can&apos;t divide 3 (represented as 111) into groups of the same size (technically you can do 3 groups of &quot;1&quot;, but then M isn&apos;t 2 or larger). &nbsp;Basically, you are checking if the number has any factors bigger than 1, which obviously is only false for prime numbers.

    318

  • @tempest_dawn · 1 year ago

    love that the halloween horror episode on a math channel is . . . code

    1.6K

  • @busyfreeguy · 1 year ago

    15+ years of programming experience including using regular expressions and I still watched and enjoyed this video. It&apos;s a testament to Matt&apos;s enthusiasm and his skill as a speaker/teacher.

    891

  • @mckseal · 1 year ago

    Regex is already halloween worthy.

    1.1K

  • @tostadojen · 1 year ago

    <b>Matt:</b> &quot;What the factor?&quot;<br><b>Primes:</b> &quot;Your factors can&apos;t help you here.&quot;

    56

  • @linguica · 1 year ago

    I love regular expressions. I taught myself to use them in college and then as an intern doing data entry I was able to complete a full day&apos;s &quot;work&quot; in like 30 minutes.

    12

  • @Rohanology27 · 1 year ago (edited)

    What in the ^.?$|^(..+?)\1+$ did I just watch?<br><br>Edit: Added

    764

Up next

LIVE

Beware the Runge Spikes!

Stand-up Maths · 560K views

LIVE

How lucky is too lucky?: The Minecraft Speedrunning Dream Controversy Explained

Stand-up Maths · 8.2M views

LIVE

The Immortal Kangaroo Sequence - Numberphile

Numberphile · 355K views

LIVE

Calculating pi from coin flips (without randomness)

Stand-up Maths · 387K views

LIVE

The rest of the world does names differently.

RobWords · 1.1M views

LIVE

'Experimenting with Primes' - Dr Holly Krieger

Millennium Mathematics Project - maths.org · 348K views

LIVE

The Professor Who Taught People How To Think (1962)

ABC Science and ABC Australia · 2.9M views

LIVE

MUST WATCH: Obama Gives Deep Take On AI Threat, Recursive Self-Improvement, & His Suggested Approach

Forbes Breaking News · 720K views

LIVE

Exploring the mysteries of the Prime (gaps!) Line.

Stand-up Maths · 670K views

LIVE

The Bingo Paradox: 3× more likely to win

Stand-up Maths · 952K views

LIVE

So You Want to Understand Quantum Mechanics…

PBS Space Time · 1.8M views

LIVE

The Most Controversial Idea In Math

Veritasium · 14M views

LIVE

How (and why) to take a logarithm of an image

3Blue1Brown · 2.2M views

LIVE

Mathematicians finally find the infinite card game.

Stand-up Maths · 444K views

LIVE

Why π^π^π^π could be an integer (for all we know!).

Stand-up Maths · 4M views

LIVE

The Hidden Structure of Rule 30

Eric Rowland · 252K views

LIVE

Why was this visual proof missed for 400 years? (Fermat's two square theorem)

Mathologer · 990K views

LIVE

The last IMO problem AI could not solve

3Blue1Brown and PolyaMath · 2.6M views

LIVE

Anthropic Took On the Riemann Hypothesis. Here’s What Actually Happened

Ellie Sleightholm · 481K views

LIVE

What happens if you just keep squaring?

Veritasium · 10M views

LIVE

Why it’s mathematically impossible to share fair

Stand-up Maths · 2.1M views

LIVE

The hardest "What comes next?" (Euler's pentagonal formula)

Mathologer · 842K views

LIVE

How Roman numerals broke the official dog database.

Stand-up Maths · 874K views

LIVE

The biggest hand calculation in a century! [Pi Day 2024]

Stand-up Maths · 547K views

LIVE

I designed a silly but semi-functional computer.

Stand-up Maths · 328K views

LIVE

Has a Millennium Prize Problem been solved by AI?

Stand-up Maths · 1.1M views

YouTube, with the door locked.

Aegis plays a clean stream instead of YouTube's player, so pre-roll ads, trackers, and fingerprinting never ride along. Drop Shields any time if you want the official player back.