### 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,129 hits

Programming Enigma Puzzles

23 December 2019

Posted by on **From New Scientist #1683, 23rd September 1989** [link]

“Four-armed is four-warmed,” declared Professor Törqui as he placed the petits fours in the oven in his lab at the Department of Immaterial Science and Unclear Physics. “There are 4444 of them: a string of 4s. By which I mean, naturally enough, a number in base 10

allof whose digits are 4. Do you like my plus fours? [*] Speaking of 10s and plus fours, you can hardly be unaware of the fact that all positive integral powers of 10 (except 10¹, poor thing) are expressible as sums of strings of 4s.”“The most economical way of expressing 10² as a sum of strings of 4s (that is, the one using fewest strings and hence fewest 4s) uses seven 4s:”

10² = 44 + 44 + 4 + 4 + 4.

“The most economical means of expressing 10³ as a sum of strings of 4s requires sixteen 4s:”

10³ = 444 + 444 + 44 + 44 + 4 + 4 + 4 + 4 + 4 + 4.

“Now, it’s four o’clock, and just time for this puzzle: Give me somewhere to put my cakestand and I will make a number of petits fours which is an integral positive power of 10 such that the number of 4s required to write it as a sum of strings of 4s in the most economical way is itself a string of 4s.”

What is the smallest number of petits fours Törqui’s boast would commit him to baking? (Express your answer as a power of 10.)

[*] £44.44 from Whatsit Forum.

[enigma531]

%d bloggers like this:

We can denote a repdigit consisting of

nrepeats of the digit 4 as:4[n].Now, if we consider a power of 10, say

10^k(for sufficiently largek).Then we can subtract the repdigit

4[k]from it twice, leaving: 11…12 (with(k – 1)1’s).From this we can subtract the repdigit

4[k – 1]twice, leaving: 22…224 (with(k – 2)2’s).From this we can subtract the repdigit

4[k – 2]five times, leaving 4.So we get:

The number of times the digit 4 is used is thus:

And we see that 10² requires 9×2 – 11 = 7 digits and 10³ requires 9×3 – 11 = 16 digits, as given in the puzzle text.

So we need to find when

(9k – 11)is a repdigit composed entirely of 4’s.Hence 10^495 can be expressed using 4444 copies of the digit 4.

Run:[ @repl.it ]Solution:The smallest possible number is 10^495.This is an infeasibly large number of cakes to bake.

We can see that the repdigits of 4, plus eleven are:

The number will be divisible by 9 if the sum of its digits is:

Which is divisible by 9 if:

So:

From which we can calculate the increasing powers of 10 that solve the puzzle:

In general the solutions can be characterised as:

So the possible powers of 10 get even more ludicrously huge very quickly.

This problem would also work for the repdigits 1, 2, 5 and 8 giving a total of 5 possible ways, {1, 2, 4, 5, 8}.

I reduced the problem to 5 functions that would generate the powers for each digit varient, namely:-

Repdigit 1 is (1/81*10^(9 n) – 8) – 10/81

Repdigit 2 is (1700 + 10^(9 n))/4050

Repdigit 4 is 4/81*(10^((9 n) – 5) – 1) + 11/9

Repdigit 5 is 5/81*(10^((9 n) – 5) – 1) + 7/9

Repdigit 8 is 8/81*(10^((9 n) – 8) – 1) + 19/9

For all n. Which generates the following numbers for n = 1 to 4

Repdigit 1 , {0,123456790,123456790123456790,123456790123456790123456790}

Repdigit 2 , {246914,246913580246914,246913580246913580246914,246913580246913580246913580246914}

Repdigit 4 , {495,493827160495,493827160493827160495,493827160493827160493827160495}

Repdigit 5 , {618,617283950618,617283950617283950618,617283950617283950617283950618}

Repdigit 8 , {3,987654323,987654320987654323,987654320987654320987654323}

For the Repdigit 1 we have 9k + 1, simplifies to 9k + 1

For the Repdigit 2 we have 4k + 5(k-1) + 1, simplifies to 9k – 4

For the Repdigit 4 we have 2k + 2(k-1) + 2(k-2) + 1 simplifies to 9k – 11

For the Repdigit 5 we have k + 8(k-1) + 1 simplifies to 9k – 7

For the Repdigit 8 we have k + (k-1) + 2(k-2) + 5(k-3) + 1 simplifies to 9k – 19

A test for the digit 2, first solution 246914, we have the number of 2’s as (4*246914) + (5*246913) + 1 = 2222222