Project Euler 130: Finding composite values, n, for which n−1 is divisible by the length of the smallest repunits that divide it.

Project Euler 130: Finding composite values, n, for which n−1 is divisible by the length of the smallest repunits that divide it.

Problem 130 of Project Euler is a continuation of problem 129, so if you have already solved that this one should be pretty easy. It reads

Find the sum of the first twenty-five composite values of n for which GCD(n, 10) = 1 and n – 1 is divisible by A(n).

If you have already solved Problem 129 as we have, this one can be solved pretty easily. We already have a function that will give us A(n), so we can just brute force our way through the problem calculating check if n-1 is divisible by A(n) and n is not a prime.

Read this article…
UVa 102: Ecological Bin Packing

UVa 102: Ecological Bin Packing

Problem 102 at the UVa online judge deals with a special kind of bin packing problem, where we are asked to recycle glass in the most efficient way possible.

We solve the problem by simple brute force. It may though be harder to implement than might seem at first sight. In any case, this is yet another easy problem from the UVa online judge.

Read this article…
Project Euler 129: Investigating minimal repunits that divide by n.

Project Euler 129: Investigating minimal repunits that divide by n.

Problem 129 of Project Euler reads

A number consisting entirely of ones is called a repunit. We shall define R(k) to be a repunit of length k; for example, R(6) = 111111.

Given that n is a positive integer and GCD(n, 10) = 1, it can be shown that there always exists a value, k, for which R(k) is divisible byn, and let A(n) be the least such value of k

Find the least value of n for which A(n) first exceeds one-million.

This problem can be solved by applying the principles of long division so we avoid having to multiply extremely large numbers

Read this article…
Merry Christmas

Merry Christmas

A very merry Christmas to all of you out there. If you don’t celebrate Christmas, I still wish you a happy on of them. It is a wonderful time to spend time with your families and I hope that you all got something nice for and mathy for Christmas. Personally I use some of the […]

Read this article…
Project Euler 128: Which tiles in the hexagonal arrangement have prime differences with neighbours?

Project Euler 128: Which tiles in the hexagonal arrangement have prime differences with neighbours?

Problem 128 is a really interesting problem about prime numbers. It reads

A hexagonal tile with number 1 is surrounded by a ring of six hexagonal tiles, starting at “12 o’clock” and numbering the tiles 2 to 7 in an anti-clockwise direction.
New rings are added in the same fashion, with the next rings being numbered 8 to 19, 20 to 37, 38 to 61, and so on.
By finding the difference between tile n and each its six neighbours we shall define PD(n) to be the number of those differences which are prime.
It can be shown that the maximum value of PD(n) is 3. Find the 2000th with PD(n) = 3.

My initial thought was that it will kill me if I have to go through every number and check if they fulfill the criteria, so I started looking for patterns such that I could eliminate some numbers that I did not have to check.

Read this article…
Project Euler 127: Investigating the number of abc-hits below a given limit.

Project Euler 127: Investigating the number of abc-hits below a given limit.

Problem 127 of Project Euler is a really awesome number theoretic problem using concepts of GCD and radicals. The problem reads The radical of n, rad(n), is the product of distinct prime factors of n. For example, 504 = 23 x 32 x 7, so rad(504) = 2 x 3 x 7 = 42. We shall define the triplet of positive integers (a, b, c) […]

Read this article…
Project Euler 126: Exploring the number of cubes required to cover every visible face on a cuboid.

Project Euler 126: Exploring the number of cubes required to cover every visible face on a cuboid.

Problem 126 of Project Euler is a really awesome geometric challenge. It reads

We shall define C(n) to represent the number of cuboids that contain n cubes in one of its layers. So C(22) = 2, C(46) = 4, C(78) = 5, and C(118) = 8.

It turns out that 154 is the least value of n for which C(n) = 10.

Find the least value of n for which C(n) = 1000.

The first thing we should do is to figure out if we can deduce a formula to calculate the number of cubes needed to cover the previous layer.

Read this article…
Project Euler 125: Finding square sums that are palindromic

Project Euler 125: Finding square sums that are palindromic

Problem 125 of Project Euler deals with a property we have worked with before, palindromic numbers. The problem reads

Find the sum of all the numbers less than 108 that are both palindromic and can be written as the sum of consecutive squares.

I don’t think there is a way we can avoid checking a whole lot of numbers. However, we can either generate all palindromic numbers and check if them are sum of squares. Or we can go the other way and generate all sum of squares and check if they are palindromes. I took the latter approach since we already have an efficient solution for check if a number is palindromic.

Read this article…
Project Euler 124: Determining the kth element of the sorted radical function

Project Euler 124: Determining the kth element of the sorted radical function

Problem 124 of Project Euler deals with radical functions, something I have never heard of before. So that always makes it interesting. It reads

The radical of n, rad(n), is the product of distinct prime factors of n. For example, 504 = 23 x 32 x 7, so rad(504) = 2 x 3 x 7 = 42.
If rad(n) is sorted for 1 ≤ n ≤ 100000, find E(10000).

At first I thought I could do it by generating number with the smallest radical number, such that I started by taking 2, 4, 8, 16… which are all multiple of 2. Followed by 3,9, 27….. But then I realized that I had to keep track of that I should take the numbers with a radical of 5, followed by 2*3 followed by 7, and soon it started to seem a lot less like a good idea. So I abandoned the idea of just generating the numbers in the correct order until I reached E(10000).

Read this article…
Constructive criticism – A viewpoint from the soap boax

Constructive criticism – A viewpoint from the soap boax

Lately quite a few comments trickle in to mathblog, and I absolutely love that. Everything from pointing out mistakes, showing solutions, given pointers for other solution methods and all the way to disagreeing with me. As everyone who has posted a comment also know, is that I hold all comments for moderation. I do that mainly in order […]

Read this article…
This site uses cookies.