<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Number-Theory on</title><link>https://h30306.github.io/blog/tags/number-theory/</link><description>Recent content in Number-Theory on</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>hwork0511@gmail.com (Wei Yi Chung)</managingEditor><webMaster>hwork0511@gmail.com (Wei Yi Chung)</webMaster><copyright>© 2026 Wei Yi Chung</copyright><lastBuildDate>Mon, 02 Nov 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://h30306.github.io/blog/tags/number-theory/index.xml" rel="self" type="application/rss+xml"/><item><title>LeetCode 4098: Minimize the Maximum Value of GCD-Connected Array</title><link>https://h30306.github.io/blog/leetcode/leetcode-4098/</link><pubDate>Mon, 02 Nov 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-4098/</guid><description>LeetCode 4098 note: value&amp;rsquo;s smallest prime factor p decides everything: the next element is at least value + p, then even numbers step by 2; the left side is feasible iff value - p &amp;gt;= 2 * index</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-4098/featured.png"/></item><item><title>Number Theory</title><link>https://h30306.github.io/blog/algorithm/number-theory/</link><pubDate>Tue, 20 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/algorithm/number-theory/</guid><description>GCD, primality tests, the sieve of Eratosthenes / linear sieve / smallest prime factor (SPF), connecting numbers by prime factors with Union-Find, and splitting an array by the last occurrence of prime factors</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/algorithm/number-theory/featured.png"/></item><item><title>LeetCode 2584: Split the Array to Make Coprime Products</title><link>https://h30306.github.io/blog/leetcode/leetcode-2584/</link><pubDate>Tue, 13 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-2584/</guid><description>LeetCode 2584 note: coprime products ⇔ no prime factor in both parts; record each prime&amp;rsquo;s last index, extend reach left to right, and split after i when reach == i</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2584/featured.png"/></item><item><title>LeetCode 4081: Prime Subset Selection II</title><link>https://h30306.github.io/blog/leetcode/leetcode-4081/</link><pubDate>Tue, 13 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-4081/</guid><description>LeetCode 4081 note: sieve the primes, then 0/1 knapsack with dp[j] the fewest primes summing to j; adding primes from large to small, a tie gives a smaller first element, so updating on &amp;lt;= yields the lexicographically smallest</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-4081/featured.png"/></item><item><title>LeetCode 1998: GCD Sort of an Array</title><link>https://h30306.github.io/blog/leetcode/leetcode-1998/</link><pubDate>Mon, 12 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-1998/</guid><description>LeetCode 1998 note: numbers in one component can be permuted freely; union each number with its prime factors via SPF, and the array sorts iff each position&amp;rsquo;s old and new values share a group</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1998/featured.png"/></item><item><title>LeetCode 2523: Closest Prime Numbers in Range</title><link>https://h30306.github.io/blog/leetcode/leetcode-2523/</link><pubDate>Mon, 12 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-2523/</guid><description>LeetCode 2523 note: sieve the primes in range, since only adjacent primes can be closest; or trial-divide rightward from left and stop at the first twin primes with gap 2</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2523/featured.png"/></item><item><title>LeetCode 2761: Prime Pairs With Target Sum</title><link>https://h30306.github.io/blog/leetcode/leetcode-2761/</link><pubDate>Mon, 12 Oct 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-2761/</guid><description>LeetCode 2761 note: sieve primes below n, then try x up to n / 2; when x and n - x are both prime, they form a pair</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2761/featured.png"/></item><item><title>LeetCode 1627: Graph Connectivity With Threshold</title><link>https://h30306.github.io/blog/leetcode/leetcode-1627/</link><pubDate>Sat, 05 Sep 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-1627/</guid><description>LeetCode 1627 note: no pairwise GCDs; for each z &amp;gt; threshold, connect all multiples of z, O(n log n) unions in total</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1627/featured.png"/></item><item><title>LeetCode 3984: Divisible Game</title><link>https://h30306.github.io/blog/leetcode/leetcode-3984/</link><pubDate>Mon, 06 Jul 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-3984/</guid><description>LeetCode 3984 note: replacing a composite k by one of its prime factors only helps (more values divisible, smaller k), so try every prime factor of the numbers plus 2, running Kadane once per candidate</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-3984/featured.png"/></item><item><title>LeetCode 3918: Sum of Primes Between Number and Its Reverse</title><link>https://h30306.github.io/blog/leetcode/leetcode-3918/</link><pubDate>Sun, 03 May 2026 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-3918/</guid><description>LeetCode 3918 note: reverse n, take the range [min, max], and sum primes by trial division; test divisibility with %, never by comparing // with /</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-3918/featured.png"/></item><item><title>LeetCode 2413: Smallest Even Multiple</title><link>https://h30306.github.io/blog/leetcode/leetcode-2413/</link><pubDate>Wed, 17 Dec 2025 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-2413/</guid><description>LeetCode 2413 note: lcm(2, n), which is n when n is even and 2n when odd</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2413/featured.png"/></item><item><title>LeetCode 2709: Greatest Common Divisor Traversal</title><link>https://h30306.github.io/blog/leetcode/leetcode-2709/</link><pubDate>Thu, 07 Aug 2025 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-2709/</guid><description>LeetCode 2709 note: every pair of indices connects ⇔ one component; factor with SPF and union each number with its prime factors in Union-Find, treating 1 specially</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-2709/featured.png"/></item><item><title>LeetCode 3618: Split Array by Prime Indices</title><link>https://h30306.github.io/blog/leetcode/leetcode-3618/</link><pubDate>Sat, 19 Jul 2025 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-3618/</guid><description>LeetCode 3618 note: primality is about the index; a sieve of Eratosthenes marks all of 0..n-1 at once, faster than trial division per index</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-3618/featured.png"/></item><item><title>LeetCode 1979: Find Greatest Common Divisor of Array</title><link>https://h30306.github.io/blog/leetcode/leetcode-1979/</link><pubDate>Sat, 17 May 2025 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-1979/</guid><description>LeetCode 1979 note: find the minimum and maximum, then take their GCD with Euclid&amp;rsquo;s algorithm</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-1979/featured.png"/></item><item><title>LeetCode 952: Largest Component Size by Common Factor</title><link>https://h30306.github.io/blog/leetcode/leetcode-952/</link><pubDate>Sat, 10 May 2025 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-952/</guid><description>LeetCode 952 note: sharing a factor ⇔ sharing a prime factor; factor each number and union indices with the same prime factor using Union-Find, with no pairwise GCDs</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-952/featured.png"/></item><item><title>LeetCode 204: Count Primes</title><link>https://h30306.github.io/blog/leetcode/leetcode-204/</link><pubDate>Fri, 11 Nov 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-204/</guid><description>LeetCode 204 note: the sieve of Eratosthenes, crossing out multiples of each prime p starting at p², with the outer loop only up to √n</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-204/featured.png"/></item><item><title>LeetCode 258: Add Digits</title><link>https://h30306.github.io/blog/leetcode/leetcode-258/</link><pubDate>Mon, 22 Aug 2022 00:00:00 +0000</pubDate><author>hwork0511@gmail.com (Wei Yi Chung)</author><guid>https://h30306.github.io/blog/leetcode/leetcode-258/</guid><description>LeetCode 258 note: sum the digits repeatedly until one remains; the O(1) answer is the digital root 1 + (n - 1) % 9</description><media:content xmlns:media="http://search.yahoo.com/mrss/" url="https://h30306.github.io/blog/leetcode/leetcode-258/featured.png"/></item></channel></rss>