Enigma 1436 – One More Step

Enigma 1436 – One More Step

Here’s this weeks problem:

Consider the following set of numbers:

1, 3, 7, 13, 21…

Send in the following:

a) The 600th member of the series

b) A member of the series above the first with less than five digits which is a perfect cube

c) A member of which is a five-digit palindrome which can also be read as a binary number

d) The smaller of the two consecutive members which are 1000 apart

Oh the joys. Yet another one that can be solved with a brute force method.

First we have to find out an how the sequence is generated. Looking at it carefully we can see it increments first by 2, then 4, 6, 8… To generate this sequence we do simply this: (n-1) * n + 1

A – 600th member

To calulate this just set n to be 600. This gives us: 599 * 600 +1 = 359401

B – perfect cube first with less than 5 digits.

Perfect cubes is simply the third power of an integer. To solve this we need to get all the perfect cubes with up to 4 digits and compare them against the members of the series. Lets do it with some php. First the cube array.

$cubesArray = array(); for($a = 2; $a <= 21; $a++) { $cube = $a*$a*$a; array_push($cubesArray,$cube); }

We know that the cube of 21 is the largest perfect cube with less than 5 digits so we only need the cubes up to there. No we need the corresponding array for the series and then loop through them and compare.

$seriesArray = array(); for($b = 1; $b <=600; $b++) { $value = ($b-1) * $b+1; array_push($seriesArray, $value); } foreach ($cubesArray as $currentCube) { if (in_array($currentCube, $seriesArray) { echo ‘Perfect Cube in Series: ‘.$currentCube; break; } }

From this we get the answer to be 343

C – The palindrome

This is relatively simple. The two contraints of it being the number being a palindrome, 5 digits and being able to be read as a binary leave us with only 4 options, 10001, 10101, 11011, 11111. Of these, a little bit of trial and error, leaves us with the answer as 10101. Simple

D – consective 1000 apart

Oooo. Harder. No, well not really. We can do this again with a simple bit of php.

for ($c = 0; $c <=599; $c++) { if(($seriesArray[$c] + 1000 == $seriesArray[$c+1]) { echo ‘the lowest consecutive member is: ‘.$seriesArray[$c]; break; } }

This spits out the answer 249501.

So to recap my answers are as follows:

  • a) 359401
  • b) 343
  • c) 10101
  • d) 249501

Go Maths!