A YouTuber Got a Sequence Into the OEIS With XOR Math
Gary Explains got an original integer sequence accepted into the OEIS by XOR-ing numbers in loops. Here's why that's genuinely fascinating—and what it connects to.
Written by AI. Zara Chen

Photo: AI. Henrik Solberg
Okay so I found this video at some deeply unreasonable hour and I need to tell you about it, because I have not stopped thinking about it since.
Gary, who runs the YouTube channel Gary Explains, just got an original mathematical sequence accepted into the Online Encyclopedia of Integer Sequences — the OEIS, which is basically the canonical archive of every interesting number pattern humans have catalogued since Neil Sloane started collecting them in the 1960s (the online database itself went live in 1996, but the obsession clearly started earlier). The OEIS has hundreds of thousands of sequences in it. Primes, Fibonacci, all the classics. And now it has Gary's. Sequence A396572, to be exact.
That's not a small thing? Like, someone just did that. Not a professor, not a research team — a guy who makes YouTube videos about tech, playing around with numbers "just in my head for fun and recreation," as he puts it. He found something nobody had formally catalogued, submitted it, and it got accepted. I find that extremely good news about the world.
First: XOR Is Secretly Genius, and Here's Why
Before we can talk about the sequence itself, we need to talk about XOR, because it's the engine of everything here and it's one of those ideas where once it clicks, you kind of can't believe it works.
XOR — exclusive or — is a logical operation with one rule: it returns true if exactly one of its two inputs is true. Both true? Zero. Both false? Zero. One true, one false? One. That's it.
The part that makes it feel like a magic trick is what Gary calls the reversibility property. If A XOR B = C, then C XOR B gets you back to A, and C XOR A gets you back to B. You have three numbers, but any two of them reconstruct the third. He uses the example: 133 XOR 88 = 221. And 221 XOR 88 = 133. You can run it backwards. This, Gary explains, is exactly why RAID storage works — if you lose one disk but you have the XOR result stored elsewhere, you can reconstruct the lost data. Same trick powers certain encryption schemes.
So XOR isn't just a logic gate, it's a relationship between numbers. Hold that thought.
A Loop of Numbers That Keeps Eating Itself
Here's where Gary's sequence comes in. Imagine you arrange n numbers in a circle — a closed loop where every number has two neighbors. Now apply this rule: replace every number with the XOR of itself and its neighbor. Do that all the way around the loop, simultaneously. You've now produced a new set of numbers. Do it again. And again.
The question Gary asked — and I love that he just asked it, like it occurred to him in the shower or something — is: how many distinct arrangements do you see before the pattern starts repeating?
He starts with three nodes (a triangle). You run the XOR operation, get a new triangle. Run it again... and you're back where you started, just rotated. So for n = 3, you get 2 distinct states before repetition. That's the first term of the sequence.
Five nodes is more interesting. You run through four rounds of XOR before you cycle back to your starting arrangement (again, just rotated). So n = 5 gives you 4. The sequence is building.
Then there's the weird case: four nodes. Powers of two, Gary discovers, behave differently. Instead of cycling back to some rotated version of the original, they collapse — the numbers converge toward a single value repeated four times, and then XOR does something inevitable: a number XOR'd with itself is zero. So the whole thing zeros out. For n = 4, you get 5 distinct states before you hit the zeros and they just loop forever.
"It turns out when n is a power of two," Gary explains, "the state always reduces to zero."
Every power of two in the sequence gets one extra count added — that's the state where everything becomes the same value right before the zeroing happens. It creates these little spikes in the data that are predictable once you know the rule but feel surprising every time you see them.
The Part Where It Gets Genuinely Weird
What happens when you zoom out and look at the full sequence across many values of n? The numbers don't grow smoothly. They jump around in ways that don't feel intuitive. Gary points out that you can have a term of 64, and then just two positions later in the sequence, you're at 536 million. No obvious ramp-up. No warning. Small numbers sandwiched between enormous ones with no clear pattern to the placement.
This is the thing I keep coming back to. The rule is simple — XOR adjacent pairs, go around the loop, count states before repetition. You can teach this to someone in five minutes. But the sequence it produces is not simple. It's not monotonically increasing, it's not obviously periodic, it's not anything you'd predict just by knowing the rule.
Gary connects this to two other known sequences from the OEIS. One tracks the highest power of two that divides n. The other — this is where it gets genuinely strange — describes "the eventual period of a single cell in a Rule 90 cellular automaton in a cyclic universe with width n." Rule 90 is an elementary cellular automaton that generates its next state using XOR on neighboring cells, wrapped in a loop. Gary found that if you add those two other sequences together, term by term, you get his sequence. His sequence is their sum.
"These three kind of live together," Gary says, "although they're very different parts of mathematics, very different ideas — and they come together when you join them using my sequence."
That's a wild thing to discover when you're just noodling on a problem for fun. Three sequences from different mathematical neighborhoods, and they turn out to be secretly in conversation with each other.
What You Actually Do With This Information
Here's what I can't stop thinking about: Gary doesn't know why the sequences add up that way. He observes it, verifies it, demonstrates it — but the deeper reason, if there is one, is still sitting there waiting for someone to dig it out.
This is the part that nobody really talks about when they talk about math. You can make a genuine, verifiable, original observation about how numbers behave — an observation real enough to get accepted into a serious database — and still not have any idea what it means or what it's for. You contribute the discovery and leave the interpretation on the table for whoever picks it up next. That's not a failure state. That's how a huge amount of mathematical knowledge actually accumulates — person by person, observation by observation, someone just going "wait, these things add up... and they shouldn't have to."
The OEIS exists precisely to catch those moments before they disappear. Sloane built it as a way to store the "huh, interesting" before anyone knew if it was useful, because sometimes the "huh, interesting" turns out to be foundational decades later, and sometimes it just sits there being interesting, and both of those outcomes are fine.
Gary ended up in the database because he was curious and persistent, not because he had a research agenda. His sequence — A396572, number of distinct states before repetition for a circular array of n distinct elements under repeated adjacent XOR operations — is now part of that permanent record. Someone out there will eventually open it and go "oh, that's the thing I needed."
Or they won't, and it'll just be a genuinely beautiful pattern that one person found by playing around late at night, which is, honestly, also kind of perfect. 🧮
Zara Chen is a tech and politics correspondent for Buzzrag.
We Watch Tech YouTube So You Don't Have To
Get the week's best tech insights, summarized and delivered to your inbox. No fluff, no spam.
More Like This
Have Astronomers Found the Universe's Missing Mass?
Astronomers may have discovered the universe's missing mass in cosmic filaments, a breakthrough in understanding cosmic evolution.
Solar Flares, Earth's Magnetosphere, and StormWall
Recent X-class solar flares and CMEs have prompted serious discussion about Earth's space weather vulnerability—and a theoretical plasma shield called StormWall.
Exploring Black Holes and Asteroids with StarTalk
Neil deGrasse Tyson delves into black holes, asteroids, and more in StarTalk's latest Cosmic Queries episode with Chuck Nice.
Why NASA Is Finally Returning to Venus After 40 Years
After decades of neglect, Venus is getting two NASA missions. Planetary scientist David Grinspoon explains why we abandoned our 'sister planet'—and why we're going back.
YouTube's Algorithm Doesn't Care If You're Monetized
A YouTube employee reveals what actually affects your views: it's not monetization, AI, or shadowbans—it's whether your content has a fingerprint.
Google Gemini's Free Update Lets Anyone Build Apps
Google's new Gemini features—including Vibe Coding and Stitch—claim to turn anyone into a developer. But can AI really replace technical expertise?
RAG·vector embedding
2026-06-30This article is indexed as a 1536-dimensional vector for semantic retrieval. Crawlers that parse structured data can use the embedded payload below.