All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Clever counting (Posted on 2015-08-07)
Some positive integers n have the property that the sum
[ n + reverse(n) ] consists entirely of odd (decimal) digits.
For instance, 36 + 63 = 99 and 409 + 904 = 1313.
We will call such numbers reversible; so 36, 63, 409, and 904 are reversible. Leading zeroes are not allowed in either n or reverse(n).
There are 120 reversible numbers below one-thousand.

a. Evaluate how many reversible numbers are there
below 10k, k=2,3... up to 6 or 7 .

b. Analyze the results, aiming to find the relation (i.e. approximate function) between N(k) and k.

Source: Project Euler, modified.

 No Solution Yet Submitted by Ady TZIDON No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 Part b researched solution | Comment 4 of 6 |
This had been Project Euler puzzle #145.

Although the rules of the Project Euler website forbid posting answers online, there is a site that has done many of these puzzles. That site has posted a generalized formula for and number of digits:

All even numbered digits have the same formula so we can generalize that for some integer k such that n = 2k we have 20*30^(k-1) solutions. Which represents the outer pair along with all the inner pairs.

3 and 7 have the same kind of argumentation, and I have carried it out on 11 as well just to check. So for a number n = 4k + 3 for some integer k we have that the middle digit and the outer pair gives us 5 and 20 options.

Then we have sets of internal pairs which gives us 20 and 25 solutions. So that means we can generalize it to 20*5*(20*25)^(k-1) = 100*500^(k-1)

Then in order to have covered all numbers we need to cover n = 4k+ 1 which means 1, 5, 9,… and none of these have solutions.

The site follows that description with a program in c that supposedly calculates the numbers up through length 9, but I can't see that it would work: just for starters, a formula appears (case 1 in the program) for the last case described as having no solutions.

A modified version, translated to Visual Basic, is:

DefDbl A-Z
Dim crlf\$

Form1.Visible = True

Text1.Text = ""
crlf = Chr\$(13) + Chr\$(10)

For i = 1 To 25
Select Case (i Mod 4)
Case 0, 2
amt = 20 * (30 ^ ((i / 2) - 1))
Case 1
amt = 0
Case 3
amt = 100 * (500 ^ ((i + 1) / 4 - 1))
End Select
tot = tot + amt
Text1.Text = Text1.Text & i & Str(amt) & Str(tot) & crlf
Next

Text1.Text = Text1.Text & ct & crlf & " done"

End Sub

finding:

(showing the top power of 10, the number of cases added since the previous power of 10, and the total of all such numbers under that power of 10)

1 0 0
2 20 20
3 100 120
4 600 720
5 0 720
6 18000 18720
7 50000 68720
8 540000 608720
9 0 608720
10 16200000 16808720
11 25000000 41808720
12 486000000 527808720
13 0 527808720
14 14580000000 15107808720
15 12500000000 27607808720
16 437400000000 465007808720
17 0 465007808720
18 13122000000000 13587007808720
19 6250000000000 19837007808720
20 393660000000000 413497007808720
21 0 413497007808720
22 1.18098E+16 1.22232970078087E+16
23 3.125E+15 1.53482970078087E+16
24 3.54294E+17 3.69642297007809E+17
25 0 3.69642297007809E+17

After 21 (for 10^21) numbers are shown in exponential format as they exceed the precision of double floating point numbers.

 Posted by Charlie on 2015-08-07 23:04:25

 Search: Search body:
Forums (0)
Random Problem
Site Statistics
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox: