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

Home > Numbers
Clever counting (Posted on 2015-08-07) Difficulty: 3 of 5
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.)
Solution part a computer solution | Comment 1 of 6
Limit is followed by number under that limit:

100 20
1000 120
10000 720
100000 720
1000000 18720
10000000 68720

DefDbl A-Z
Dim crlf$


Private Sub Form_Load()
 Form1.Visible = True
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)

 rept = 100
 For n = 1 To 10000000
  If n Mod 10 > 0 Then
    ns$ = LTrim(Str(n))
    nrs$ = ""
    For i = 1 To Len(ns)
      nrs = Mid(ns, i, 1) + nrs
    Next
    tot$ = LTrim(Str(n + Val(nrs)))
    good = 1
    For i = 1 To Len(tot)
      If InStr("13579", Mid(tot, i, 1)) = 0 Then good = 0: Exit For
    Next
    If good Then ct = ct + 1
  End If
  If n = rept Then
    Text1.Text = Text1.Text & rept & Str(ct) & crlf
    rept = 10 * rept
    DoEvents
  End If
 Next


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

  Posted by Charlie on 2015-08-07 18:59:07
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (18)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information