<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sayed Lotfy</title>
    <description>The latest articles on DEV Community by Sayed Lotfy (@lotfy2125).</description>
    <link>https://dev.to/lotfy2125</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4125294%2F5fb216bb-2f1d-4bd5-b9a3-7a609e5f6140.jpg</url>
      <title>DEV Community: Sayed Lotfy</title>
      <link>https://dev.to/lotfy2125</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lotfy2125"/>
    <language>en</language>
    <item>
      <title>Are the prime numbers really chaos? (The Prime Clock, film 1 of 6)</title>
      <dc:creator>Sayed Lotfy</dc:creator>
      <pubDate>Tue, 15 Sep 2026 06:29:48 +0000</pubDate>
      <link>https://dev.to/lotfy2125/are-the-prime-numbers-really-chaos-the-prime-clock-film-1-of-6-39ap</link>
      <guid>https://dev.to/lotfy2125/are-the-prime-numbers-really-chaos-the-prime-clock-film-1-of-6-39ap</guid>
      <description>&lt;p&gt;Six short films from the book &lt;em&gt;The Prime Clock&lt;/em&gt;, for anyone who was told at school they weren't a maths person. No formulas on screen — just counting, and watching.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Part 1 — Are the prime numbers really chaos?&lt;/strong&gt; (8 minutes)&lt;/p&gt;

&lt;p&gt;Everyone says the primes are random. This film starts there and asks one small question: what does the &lt;em&gt;last digit&lt;/em&gt; of a prime do? Every prime past 5 ends in 1, 3, 7 or 9 — and once you see that, the list stops looking like noise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The rest of the series&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Part 2 — What a prime number actually is: &lt;a href="https://www.youtube.com/watch?v=MglEOSFrYhc" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=MglEOSFrYhc&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Part 3 — Putting the four prime endings on a compass: &lt;a href="https://www.youtube.com/watch?v=IKXH9X-unGI" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=IKXH9X-unGI&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Part 4 — The moment the primes start behaving like a clock: &lt;a href="https://www.youtube.com/watch?v=Kc6RgWY8Xo8" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=Kc6RgWY8Xo8&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Part 5 — Reading the cycle backwards, and forty lines of Java: &lt;a href="https://www.youtube.com/watch?v=a9bzJqGWCQ0" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=a9bzJqGWCQ0&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Part 6 — The game, the honest limits, and where it ends: &lt;a href="https://www.youtube.com/watch?v=qXLhCK8GEmg" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=qXLhCK8GEmg&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All six are also available in Arabic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The book the films are made from&lt;/strong&gt; — &lt;em&gt;The Prime Clock: From Apparent Chaos to Hidden Order&lt;/em&gt; — is free to read in nine languages (English, Arabic, German, Spanish, French, Hindi, Italian, Portuguese, Chinese) at &lt;a href="https://primeticktock.com/books" rel="noopener noreferrer"&gt;https://primeticktock.com/books&lt;/a&gt;, or as Kindle / paperback on Amazon: &lt;a href="https://www.amazon.com/dp/B0HH2Y3GGQ" rel="noopener noreferrer"&gt;https://www.amazon.com/dp/B0HH2Y3GGQ&lt;/a&gt; (currently #11 in Amazon's new releases in Number Theory).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The clock itself&lt;/strong&gt;, free, runs in any browser: &lt;a href="https://primeticktock.com" rel="noopener noreferrer"&gt;https://primeticktock.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The developer write-up&lt;/strong&gt; of how it was built and what didn't survive testing: &lt;a href="https://dev.to/lotfy2125/every-prime-ends-in-1-3-7-or-9-put-them-on-a-compass-and-you-get-a-clock-jap"&gt;https://dev.to/lotfy2125/every-prime-ends-in-1-3-7-or-9-put-them-on-a-compass-and-you-get-a-clock-jap&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It proves nothing and predicts nothing. It's a way of seeing something you already knew — and Part 6 is honest about the limits. If you think I've got something wrong, say so in the comments; that's what they're for.&lt;/p&gt;

</description>
      <category>math</category>
      <category>beginners</category>
      <category>learning</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Every prime ends in 1, 3, 7 or 9. Put them on a compass and you get a clock</title>
      <dc:creator>Sayed Lotfy</dc:creator>
      <pubDate>Tue, 15 Sep 2026 04:38:24 +0000</pubDate>
      <link>https://dev.to/lotfy2125/every-prime-ends-in-1-3-7-or-9-put-them-on-a-compass-and-you-get-a-clock-jap</link>
      <guid>https://dev.to/lotfy2125/every-prime-ends-in-1-3-7-or-9-put-them-on-a-compass-and-you-get-a-clock-jap</guid>
      <description>&lt;p&gt;On my first day learning Java I met a sentence I expected to be technical: &lt;strong&gt;everything is an object.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An object is created, it does its work, it ends. The instructor moved on to constructors. I didn't. I kept turning the sentence over on the drive home. If everything is an object — if that's really how we're meant to see a program — what happens if you look at &lt;em&gt;numbers&lt;/em&gt; that way? Not as values, but as things with a lifecycle: a beginning, a life, an end.&lt;/p&gt;

&lt;p&gt;That question followed me for five years. This is what came out of it, and — because this is a room full of people who test things — what didn't survive testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  The object model of a prime
&lt;/h2&gt;

&lt;p&gt;A composite number has a social life. 12 is born at 1, and along the way it's touched by 2, 3, 4 and 6 before it gets to itself. Its path crosses everyone's.&lt;/p&gt;

&lt;p&gt;A prime is different. It's born at 1 and ends at itself, and &lt;em&gt;nothing&lt;/em&gt; touches it in between. A short, sealed lifecycle. No dependencies. If you were modelling numbers as objects, primes would be the immutable value types.&lt;/p&gt;

&lt;p&gt;That was the whole starting point. It doesn't prove anything. But it changed what I looked at next.&lt;/p&gt;

&lt;h2&gt;
  
  
  The four constructors
&lt;/h2&gt;

&lt;p&gt;Every prime past 5 ends in 1, 3, 7 or 9. That's not a pattern, it's arithmetic: anything ending in an even digit divides by 2, anything ending in 5 divides by 5. Four possible last digits, and every prime from 7 onward gets exactly one of them.&lt;/p&gt;

&lt;p&gt;So — thinking in objects — there are four &lt;em&gt;kinds&lt;/em&gt; of prime, and each kind has its own factory. I put them in four parallel lanes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lane 1:  11, 31, 41, 61, 71, 101, ...
lane 3:  13, 23, 43, 53, 73,  83, ...
lane 7:  17, 37, 47, 67, 97, 107, ...
lane 9:  19, 29, 59, 79, 89, 109, ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The lanes don't take turns. They advance independently — each one just takes the next prime with its ending, whenever one arrives. Row &lt;em&gt;n&lt;/em&gt; of the table is the &lt;em&gt;n&lt;/em&gt;-th object each factory produced.&lt;/p&gt;

&lt;p&gt;Then I put the four endings on a compass — 1 north, 3 east, 7 south, 9 west — and let a hand jump to whichever lane fired most recently. I built it in Angular so I could watch it run. That's the app at &lt;a href="https://primeticktock.com" rel="noopener noreferrer"&gt;primeticktock.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And watching it, the list of primes stopped looking like a list. It started looking like a clock. The hand turns. Mostly clockwise.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measuring the clock
&lt;/h2&gt;

&lt;p&gt;"Mostly clockwise" is the kind of claim that gets a developer fired, so I measured it. Over every prime below 30,000,000 — 1,857,854 consecutive steps:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Move&lt;/th&gt;
&lt;th&gt;Share&lt;/th&gt;
&lt;th&gt;If random&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Clockwise&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;31.0%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;25%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Across&lt;/td&gt;
&lt;td&gt;28.6%&lt;/td&gt;
&lt;td&gt;25%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Counter-clockwise&lt;/td&gt;
&lt;td&gt;23.7%&lt;/td&gt;
&lt;td&gt;25%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stay&lt;/td&gt;
&lt;td&gt;16.8%&lt;/td&gt;
&lt;td&gt;25%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The clock leans. And the reason turns out to be completely mundane once you see it. With the endings in the order 1 → 3 → 7 → 9, a small step forward on the number line is a small step clockwise on the dial. Twin primes (gap 2) are &lt;em&gt;always&lt;/em&gt; one clockwise quarter-turn. A gap of 8 is &lt;em&gt;always&lt;/em&gt; counter-clockwise. Small gaps are more common than large ones. So the hand leans clockwise because primes are usually close together.&lt;/p&gt;

&lt;p&gt;That's a nice thing to watch. It is not a discovery. Chebyshev noticed the uneven distribution of prime endings in 1853, and Lemke Oliver and Soundararajan at Stanford mapped how consecutive primes avoid repeating an ending in 2016. I'm standing on their work and saying "look, it turns."&lt;/p&gt;

&lt;h2&gt;
  
  
  What failed in testing
&lt;/h2&gt;

&lt;p&gt;The table looks like it should predict things. Three cells in a row filled, one empty — surely the empty cell tells you the next prime's ending?&lt;/p&gt;

&lt;p&gt;I tested it. It scores &lt;strong&gt;25.4%&lt;/strong&gt; against a coin-flip's 25%. You can break it by hand: after placing every prime up to 47, the empty cell says the next prime ends in 9. The next prime is 53.&lt;/p&gt;

&lt;p&gt;I'd believed that rule for about two years. Writing the test that killed it was the most useful afternoon of the project.&lt;/p&gt;

&lt;h2&gt;
  
  
  What survived
&lt;/h2&gt;

&lt;p&gt;One thing. If you order the four lanes by &lt;em&gt;recency&lt;/em&gt; — which one fired most recently — that ordering carries a little more information about the next prime than the standard method mathematicians use. About 2.6 percentage points more, against a proper null model. Small, real, and I can't explain it. It might be a known consequence of something I haven't read.&lt;/p&gt;

&lt;p&gt;So I wrote it up so anyone can check the arithmetic, put it on Zenodo with a DOI, and emailed a mathematician who lives ten minutes from me with a note that said, more or less, &lt;em&gt;please tell me where this goes wrong.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why bother, if it proves nothing
&lt;/h2&gt;

&lt;p&gt;Because of who it's for. I made the app, a book and twelve short films for the person who was told at school they weren't a maths person. I was that person. The clock asks nothing of you but counting. No formulas on screen. It lets you &lt;em&gt;watch&lt;/em&gt; primes behave, feel the tug of a pattern that's really there, and then learn — from the last film — why the tug is not a law.&lt;/p&gt;

&lt;p&gt;That's the whole idea. Everything is an object. A prime is an object with a sealed lifecycle. Put four kinds on a compass and they turn into a clock. The clock is honest about what it can't do, and I've tried to be too.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;The clock (Angular, runs in any browser):&lt;/strong&gt; &lt;a href="https://primeticktock.com" rel="noopener noreferrer"&gt;primeticktock.com&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;The paper, with all the numbers:&lt;/strong&gt; &lt;a href="https://doi.org/10.5281/zenodo.22758494" rel="noopener noreferrer"&gt;doi.org/10.5281/zenodo.22758494&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Twelve short films, six in English and six in Arabic, free:&lt;/strong&gt; &lt;a href="https://www.youtube.com/playlist?list=PLLgN1gZfFc7o" rel="noopener noreferrer"&gt;YouTube playlist&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The idea is open. It may be right, it may be wrong, and I'd rather hear where it's wrong from you than not hear it.&lt;/p&gt;

</description>
      <category>java</category>
      <category>math</category>
      <category>showdev</category>
      <category>angular</category>
    </item>
  </channel>
</rss>
