top of page


Finding the Pythagorean Triplet: Project Euler Problem 9
The Challenge Project Euler Problem 9 asks us to find the unique Pythagorean triplet where a + b + c = 1000, then calculate the product abc. A Pythagorean triplet consists of three natural numbers a, b, c where: a² + b² = c² The classic example being 3² + 4² = 5² (9 + 16 = 25) The Brute Force Approach The solution above takes a straightforward nested loop approach: python import math for a in range ( 0 , 1000 ): for b in range ( 0 , 1000 ): for c in range
13 minutes ago1 min read


Finding the Largest Product in a Series: Project Euler Problem 8
Project Euler Problem 8 asks us to find the thirteen adjacent digits in a 1000-digit number that have the greatest product. It's a straightforward problem that tests our ability to work with strings, iteration, and basic arithmetic operations. The Problem Given a 1000-digit number, we need to: Extract every possible sequence of 13 consecutive digits Calculate the product of each sequence Return the maximum product found The Solution Here's my Python solution: python products
3 hours ago2 min read


Project Euler Problem 6: Sum Square Difference in Python
Found the difference between the sum of squares and the square of sums for the first 100 natural numbers. The problem: Calculate (1² + 2² + ... + 100²) vs (1 + 2 + ... + 100)² python sum_of_squares = [] sum_of_numbers = [] for i in range ( 0 , 101 ): sum_of_squares.append(i * i) sum_of_numbers.append(i) ss = sum (sum_of_squares) sn = sum (sum_of_numbers) sn2 = sn * sn print ( abs (ss - sn2)) Result: 25,164,150 The mathematical elegance here is that while bo
6 hours ago1 min read


Project Euler Problem 5 - Smallest positive number that is evenly divisible by the numbers 1-20
Finding the Smallest Multiple Using Python Project Euler Problem 5 asks us to find the smallest positive number that is evenly divisible by all numbers from 1 to 20. Let's solve it with Python. The Problem We need to find the smallest number that can be divided by each of the numbers from 1 to 20 without any remainder. For example, 2520 is the smallest number divisible by all numbers from 1 to 10. The Solution python for i in range ( 0 , 300000000 ): if i % 2 != 0
24 hours ago2 min read


Project Euler Problem 4
Finding the Largest Palindrome Product with Python Project Euler Problem 4 asks us to find the largest palindrome made from the product of two 3-digit numbers. Let's solve it with Python. The Problem A palindromic number reads the same both ways - like 9009 or 906609. We need to multiply all combinations of 3-digit numbers and identify the largest palindrome in those products. The Solution python palindrome_product = [] for i in range ( 0 , 999 ): for j in range ( 0
1 day ago1 min read


Project Euler Problem 3 - Largest Prime Factor
Project Euler Problem 3 asks us to find the largest prime factor of 600,851,475,143. This problem combines fundamental number theory with straightforward Python implementation to solve what initially seems like an intimidating challenge. The Approach My solution breaks down into three key steps: Generate prime numbers up to 1,000,000 Identify which primes are factors of our target number Return the maximum from those factors The Implementation The solution starts with a pr
1 day ago1 min read


Project Euler Problem 15 - Lattice Paths
Problem: Starting in the top-left corner of a 20×20 grid, and only being able to move right and down, how many routes are there to the bottom-right corner? At first glance, this seems like a classic dynamic programming or pathfinding problem. But I took a different approach - let the computer explore small cases, then use pattern recognition to crack the larger problem. from itertools import permutations import math from math import factorial dictionary_x = {} list_x = [0, 1
2 days ago2 min read


Project Euler #36: Double-Base Palindromes in Python 🔢
Problem: Find the sum of all numbers less than one million which are palindromic in both base 10 and base 2 (binary). Note that palindromic numbers can't include leading zeros in either base. My approach was straightforward - check every number up to 1,000,000: python double_base_palindromes = [] for i in range ( 0 , 1000000 ): y = list ( str (i)) y.reverse() x = '' .join(y) if int (x) == int (i): b = bin (i) b = b[ 2 :] c =
Dec 17, 20251 min read


Project Euler #30: Finding Numbers Equal to the Sum of Fifth Powers of Their Digits
Tackled another Project Euler challenge - this time finding all numbers that can be written as the sum of the fifth powers of their digits. The problem excludes 1 (as per the problem statement), and asks: which numbers equal the sum of their digits raised to the fifth power? For example: 4150 = 4⁵ + 1⁵ + 5⁵ + 0⁵ = 1024 + 1 + 3125 + 0 = 4150 My Python solution iterates through numbers up to 9,999,999, converts each to individual digits, calculates the sum of fifth powers, and
Dec 16, 20251 min read


Finding the Longest Prime-Generating Quadratic: Project Euler Problem 27
Project Euler Problem 27 asks us to find coefficients a and b for the quadratic expression n² + an + b that produces the maximum number of consecutive primes for n = 0, 1, 2, ... The Problem Euler discovered the remarkable quadratic formula n² + n + 41, which produces 40 primes for consecutive integer values starting from n = 0. The challenge is to find the product of coefficients a and b for the quadratic that produces the maximum number of primes, with -1000 < a < 1000
Dec 15, 20253 min read


Finding Circular Primes: A Journey Through Project Euler Problem 35
I recently tackled Project Euler's Problem 35, which asks: how many circular primes exist below one million? A circular prime is a prime number that remains prime under all rotations of its digits. For example, 197 is a circular prime because 197, 971, and 719 are all prime. The Approach My solution breaks down into three main steps: 1. Generate all primes below one million I used a straightforward trial division method to test each number for primality, storing valid primes
Dec 9, 20253 min read


Finding the First 1000-Digit Fibonacci Number: A Python Solution to Project Euler Problem 25
Project Euler Problem 25 asks us to find the index of the first Fibonacci number containing 1000 digits. While many would reach for complex mathematical formulas or libraries, sometimes a straightforward iterative approach is all you need. The Problem The Fibonacci sequence is defined as: F(1) = 1 F(2) = 1 F(n) = F(n-1) + F(n-2) for n > 2 The sequence grows rapidly: 1, 1, 2, 3, 5, 8, 13, 21, 34... and we need to find which term first reaches 1000 digits. The Solution Here's a
Dec 9, 20252 min read


Solving Project Euler Problem 16: Power Digit Sum
The Challenge Project Euler Problem 16 asks: What is the sum of the digits of the number 2^1000? This might sound intimidating at first. 2^1000 is an absolutely massive number with over 300 digits! But thanks to Python's built-in support for arbitrarily large integers, this problem becomes surprisingly approachable. My Solution Here's the code I used to solve it: python n = 2 x = 0 for i in range ( 1 , 1000 ): n += n for i in str (n): j = int (i) x += j p
Oct 7, 20252 min read


Finding Amicable Numbers: A Project Euler Solution #21
I recently worked through the Project Euler problem on amicable numbers. Here's how I approached it and what I learned along the way. What Are Amicable Numbers? Amicable numbers are pairs where each number equals the sum of the other's proper divisors. A proper divisor is any divisor except the number itself. Take 220 and 284: The proper divisors of 220 are: 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, and 110 Their sum: 1 + 2 + 4 + 5 + 10 + 11 + 20 + 22 + 44 + 55 + 110 = 284 The prop
Sep 29, 20252 min read


Solving Project Euler Problem 13: Large Sum
Project Euler Problem 13 asks us to find the first ten digits of the sum of one hundred 50-digit numbers. It's a straightforward problem that mainly tests how well you can handle large numbers in your chosen programming language. The Problem We have 100 numbers, each with exactly 50 digits: 37107287533902102798797998220837590246510135740250 46376937677490009712648124896970078050417018260538 74324986199524741059474233309513058123726617309629 ... Add them all up and return the
Sep 24, 20251 min read


Finding the largest product of 4 adjacent numbers in a Grid - Project Euler Problem 24
Given a grid 20 x 20 could you print the greatest product of 4 adjacent numbers. This is precisely what Project Euler has tasked us with doing. This problem requires thinking about index boundaries, looping in a two-dimensional manner and conditionally updating variables. The first thing to do is to read the grid into a variable: Use the numpy array to format it as a grid: Loop through the grid in the four directions and print the result of the maximum product: There you have
Sep 9, 20251 min read


Factorial Digit Sum - Project Euler #20
Consider the number 100! That is the product of all of the numbers between 1 and 100. That is to say, 1 x 2 x 3 ... x100. Project Euler has tasked us with providing the sum of the digits of that number. The first thing to do is to use the math library and the factorial function to generate the number. Following that we need to initialise a list and write each individual digit as a member of the list. Then, we just wrap that in a sum(list) and the print the answer out. Quite a
Jan 9, 20251 min read


Project Euler Problems 1 & 2: Multiples of 3 and 5 //Even Fibonacci Numbers
Project Euler is a series of mathematical questions that need the accompaniment of computer programming to solve. It is permissible to share the solution to the first 100 questions but none thereafter. The first question asks for the sum of the numbers which are divisible by 3 or 5 under 1000. The code solution is here (in python): list_x = list(range(1,1000)) list_new = [] #print(list_x) for integer in list_x: if integer % 5 == 0 or integer % 3 == 0: list_new.append(inte
Jan 1, 20251 min read
bottom of page