<?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: Pietro O.</title>
    <description>The latest articles on DEV Community by Pietro O. (@tropie71).</description>
    <link>https://dev.to/tropie71</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%2F4272712%2Fb888fec9-0b8a-4cd4-806f-2be6e5f1fbf9.png</url>
      <title>DEV Community: Pietro O.</title>
      <link>https://dev.to/tropie71</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tropie71"/>
    <language>en</language>
    <item>
      <title>From Excel to C: How Remainder Clocks Became Prime Clock Sieve</title>
      <dc:creator>Pietro O.</dc:creator>
      <pubDate>Sun, 29 Nov 2026 17:26:32 +0000</pubDate>
      <link>https://dev.to/tropie71/from-excel-to-c-how-remainder-clocks-became-prime-clock-sieve-2dm8</link>
      <guid>https://dev.to/tropie71/from-excel-to-c-how-remainder-clocks-became-prime-clock-sieve-2dm8</guid>
      <description>&lt;p&gt;I explore patterns in prime numbers as a hobby. The most satisfying part of this project happened in Excel.&lt;/p&gt;

&lt;p&gt;For each candidate number, I divided it by every prime smaller than it and added up the remainders. Then I subtracted the previous candidate’s total from the current one. In the range I tested, the resulting differences showed a pattern that made the primes easy to spot in my spreadsheet.&lt;/p&gt;

&lt;p&gt;I thought of each remainder as a clock. With division by 3, for example, the remainder goes 0, 1, 2, then back to 0 as you move through consecutive integers. Every reset marks a multiple of 3. I wanted to see what would happen if I kept clocks only for prime divisors.&lt;/p&gt;

&lt;p&gt;I brought the spreadsheet idea to ChatGPT, which wrote the C implementation. The program, &lt;strong&gt;Prime Clock Sieve&lt;/strong&gt;, uses a segmented sieve and marks composites where the clocks would reset. It generates primes in ascending order and writes one per line.&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing primes to a file
&lt;/h2&gt;

&lt;p&gt;On my Windows PC, using one thread, I compared the time to generate the primes, format them as decimal text, and write them to a file.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Upper limit&lt;/th&gt;
&lt;th&gt;Prime Clock Sieve 013&lt;/th&gt;
&lt;th&gt;primesieve 12.18&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;100 million&lt;/td&gt;
&lt;td&gt;70.68 ms&lt;/td&gt;
&lt;td&gt;361.48 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1 billion&lt;/td&gt;
&lt;td&gt;0.574 s&lt;/td&gt;
&lt;td&gt;3.434 s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In a separate check, the complete prime list up to 10 billion matched the reference output byte for byte.&lt;/p&gt;

&lt;p&gt;This is my first project on GitHub. The &lt;a href="https://github.com/Tropie71/prime-clock-sieve" rel="noopener noreferrer"&gt;Prime Clock Sieve repository&lt;/a&gt; includes the C source, a Windows executable, and the benchmark results. If you try the file-output benchmark on your machine, I’d be curious to see how the timings compare.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The Excel experiment and the idea of using prime-period clocks were mine. ChatGPT wrote the C implementation and drafted the English article from my account and the project benchmarks.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>performance</category>
      <category>opensource</category>
      <category>c</category>
    </item>
  </channel>
</rss>
