<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://jordan-alaniz.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://jordan-alaniz.github.io/" rel="alternate" type="text/html" /><updated>2026-03-22T09:48:05-05:00</updated><id>https://jordan-alaniz.github.io/feed.xml</id><title type="html">Jordan Alaniz</title><subtitle>Junior at ASCTE — exploring fire, EMS, nursing, and cybersecurity. Varsity distance runner. Wilderness First Responder.</subtitle><entry><title type="html">How I Sped Up Prime Number Computation</title><link href="https://jordan-alaniz.github.io/blog/prime-number-optimization/" rel="alternate" type="text/html" title="How I Sped Up Prime Number Computation" /><published>2025-02-10T00:00:00-06:00</published><updated>2025-02-10T00:00:00-06:00</updated><id>https://jordan-alaniz.github.io/blog/prime-number-optimization</id><content type="html" xml:base="https://jordan-alaniz.github.io/blog/prime-number-optimization/"><![CDATA[<p>One of my personal projects involved computing prime numbers as fast as possible. What started as a simple exercise turned into a deep dive on algorithm design and distributed computing.</p>

<h2 id="starting-point-trial-division">Starting Point: Trial Division</h2>

<p>The most obvious approach: for every number <code class="language-plaintext highlighter-rouge">n</code>, check if any integer from <code class="language-plaintext highlighter-rouge">2</code> to <code class="language-plaintext highlighter-rouge">√n</code> divides it evenly.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">is_prime</span><span class="p">(</span><span class="n">n</span><span class="p">):</span>
    <span class="k">if</span> <span class="n">n</span> <span class="o">&lt;</span> <span class="mi">2</span><span class="p">:</span>
        <span class="k">return</span> <span class="bp">False</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">n</span><span class="o">**</span><span class="mf">0.5</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">n</span> <span class="o">%</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">False</span>
    <span class="k">return</span> <span class="bp">True</span>
</code></pre></div></div>

<p>Simple, but slow for large ranges. Every number gets its own full check.</p>

<h2 id="the-sieve-of-eratosthenes">The Sieve of Eratosthenes</h2>

<p>Instead of checking one number at a time, the Sieve marks composites in bulk:</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">sieve</span><span class="p">(</span><span class="n">limit</span><span class="p">):</span>
    <span class="n">is_prime</span> <span class="o">=</span> <span class="p">[</span><span class="bp">True</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">limit</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
    <span class="n">is_prime</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">is_prime</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="bp">False</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">limit</span><span class="o">**</span><span class="mf">0.5</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">is_prime</span><span class="p">[</span><span class="n">i</span><span class="p">]:</span>
            <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">i</span><span class="o">*</span><span class="n">i</span><span class="p">,</span> <span class="n">limit</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">i</span><span class="p">):</span>
                <span class="n">is_prime</span><span class="p">[</span><span class="n">j</span><span class="p">]</span> <span class="o">=</span> <span class="bp">False</span>
    <span class="k">return</span> <span class="p">[</span><span class="n">i</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">is_prime</span><span class="p">)</span> <span class="k">if</span> <span class="n">v</span><span class="p">]</span>
</code></pre></div></div>

<p>This is dramatically faster for finding all primes up to a large limit, but requires memory proportional to the limit.</p>

<h2 id="taking-it-further-a-cluster">Taking It Further: A Cluster</h2>

<p>For very large ranges, I set up a small network of computers to split the work. Each machine handled a segment of the number range, and results were collected centrally.</p>

<p>The honest finding: for ranges where everything fits in memory, a well-optimized local sieve beats the cluster. Network overhead and coordination costs hurt small jobs. But the cluster showed its value for ranges too large for any single machine’s RAM.</p>

<h2 id="what-i-took-away">What I Took Away</h2>

<ul>
  <li>Algorithm choice matters more than raw hardware, up to a point</li>
  <li>Distributed computing has real overhead that has to be justified by the problem size</li>
  <li>Benchmarking with real numbers (not assumptions) is essential</li>
</ul>

<p>I’m planning to explore segmented sieves and possibly GPU-based approaches next.</p>]]></content><author><name></name></author><category term="Technical" /><category term="Python" /><category term="Algorithms" /><category term="Distributed Computing" /><summary type="html"><![CDATA[One of my personal projects involved computing prime numbers as fast as possible. What started as a simple exercise turned into a deep dive on algorithm design and distributed computing.]]></summary></entry><entry><title type="html">Welcome to My Site</title><link href="https://jordan-alaniz.github.io/blog/welcome/" rel="alternate" type="text/html" title="Welcome to My Site" /><published>2025-01-15T00:00:00-06:00</published><updated>2025-01-15T00:00:00-06:00</updated><id>https://jordan-alaniz.github.io/blog/welcome</id><content type="html" xml:base="https://jordan-alaniz.github.io/blog/welcome/"><![CDATA[<p>Welcome to my personal site! I’m Jordan Alaniz — a junior at the Alabama School of Cyber Technology and Engineering (ASCTE).</p>

<p>This site is where I document the projects I’m working on, write about things I’m learning, and keep a public record of my work in engineering, software, and athletics.</p>

<h2 id="what-youll-find-here">What you’ll find here</h2>

<ul>
  <li><strong>Projects</strong> — writeups of technical projects from school and on my own time</li>
  <li><strong>Blog</strong> — short posts on topics I’m exploring: algorithms, hardware, design thinking, and more</li>
  <li><strong>Resume</strong> — my <a href="/academics/">academic resume</a> and <a href="/athletics/">athletic profile</a></li>
</ul>

<h2 id="what-im-working-on">What I’m working on</h2>

<p>Right now I’m taking AP Computer Science A, AP Calculus, and AP Psychology while competing in outdoor Track &amp; Field — currently ranked <strong>10th in Class 3A</strong> in the 3200m. On the technical side, I’ve been experimenting with distributed computing, and I’m planning to go deeper into systems programming and cybersecurity.</p>

<p>Check back as I add more — this site is a work in progress, just like everything else.</p>]]></content><author><name></name></author><category term="General" /><category term="intro" /><summary type="html"><![CDATA[Welcome to my personal site! I’m Jordan Alaniz — a junior at the Alabama School of Cyber Technology and Engineering (ASCTE).]]></summary></entry></feed>