### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,367)
- misc (4)
- project euler (2)
- puzzle (90)
- puzzle# (48)
- site news (58)
- tantalizer (94)
- teaser (7)

### Site Stats

- 233,130 hits

Programming Enigma Puzzles

23 October 2017

Posted by on **From New Scientist #2247, 15th July 2000** [link]

Mr Meaner has now retired from teaching. As a tough arithmetic exercise each year he used to ask his class to take the number of the year and find some multiple of it which consists simply of a string of ones followed by a string of zeros. For example in 1995 one girl in the class found that the 19-digit number 1111111111111111110 was a multiple of 1995!

Mr Meaner had been asking this question every year since he started training as a teacher. On the first occasion it was a reasonably straightforward exercise and most of the class found a multiple using as few digits as possible.

It is lucky that he did not ask the question a year earlier, for that year would have required over two hundred times as many digits as that first occasion did.

In what year did Mr Meaner first ask the question?

[enigma1091]

%d bloggers like this:

Any repunit ends in 1, so it can’t have divisors of 2 or 5, so any factors of 2 or 5 in the year must be covered by the 0’s at the end of the number, and we need as many 0’s as the largest number of factors of 2 or 5 in the original year. The remaining factors need to be covered by the repunit.

The [[

`drop_factors()`

]] function was recently added to theenigma.pylibrary.This Python code runs in 80ms.

Run:[ @repl.it ]Solution:Mr Meaner first asked the question in 1950.1950 divides an 8-digit number (11111100) and 1949 divides a 1948-digit number (1…1), but this is not the largest number required in the period 1949 – 1995. 1979 requires a 1978 digit number to be constructed (1…1), and 1977 requires a 1974-digit number (1…1).

If Mr Meaner was still teaching and had set the puzzle this year (2017), the pupils would find that the shortest number possible is a string of 2016 1’s.

We

almostget a second solution to the problem with the years 1999 and 2000. 1999 requires a string of 999 1’s, and 2000 will divide 10000 (5 digits), the ratio 999/5 being just less than 200.As it is the next solution occurs with the years 2099 and 2100. 2099 requires a string of 2098 1’s, and 2100 will divide 11111100 (8 digits). 2098/8 is more than 200.

A difficult exercise without a computer. I suppose factorizing would help:

111111 = 3 × 7 × 11 × 13 × 37, so if you tack on a couple of zeros you could expect

1924 = 2² × 13 × 37 and 1925 = 5² × 7 × 11 and 1950 = 2 × 3 × 5² × 13 to be factors.

It’s a lot more work to find 1111111 = 239 × 4649 and 1912 = 2³ × 239.

Mean indeed to ask schoolchildren to do it for most other years in the range.

The repunits with 19 and 23 and 317 digits are prime. I didn’t try any more.

The term ‘repunit number’ was first coined by Alfred H Beiler in 1964 in his book – “Recreations in The Theory of Numbers:

http://primes.utm.edu/glossary/xpage/Repunit.html

I found an easy way of constructing long repunit numbers in Python, as shown in the attached snippet of code. Having found a repunit of any desired length, it is easy to check factors using the modulus function. The repunit could also be made of any other single digit.

@geoff: A quick way to construct a string of repeated characters in Python is to use the [[

`*`

]] operator on strings. So you can construct a string with 2016 1’s in it using:There is also the [[

`repdigit()`

]] function in theenigma.pylibrary that can produce repunits (or numbers composed of other repeated digits) without constructing them using strings. It is implemented like this: