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

Home > Numbers > Sequences
Just 3 digits (Posted on 2018-05-17) Difficulty: 4 of 5
A 10-digit number 2404563210 has an interesting feature: reading from left to right - any k-digit string is divisible by k.
No big deal ! IMHO there are 2492 numbers like that.

At least one of them utilizes only 3 distinct digits.

Find this number.

See The Solution Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
computer solution | Comment 2 of 4 |
The program at the bottom of the post verifies there are a total of 2492 10-digit numbers meeting the divisibility criterion. It also lists the 19 cases where only 3 different digits are used, and that none require any fewer than 3 different digits.

     n                 diff digits
1800008010      3
2404024020      3
3000060000      3
4084080840      3
4440002400      3
4444020000      3
4808048040      3
5040000000      3
5404504050      3
6636000060      3
8048040840      3
8404088040      3
8820000000      3
8880004080      3
8880004800      3
8880060060      3
8888040000      3
9060009660      3
9660000060      3

2492 done

I notice that only one has a 5 in the fifth position. I imagine one reason for that is that one of the three used digits must be a zero in the last position so it might as well be used at position 5.

A modification of the program (If uCt < 4 Or uCt > 9) finds that there's also exactly one pandigital number also meeting the divisibility criterion: 3816547290. Of course that one has to have a 5 in the fifth position so as not to duplicate the terminal zero.

DefDbl A-Z
Dim crlf$, n, ct


Private Sub Form_Load()
 Form1.Visible = True
 Text1.Text = ""
 crlf = Chr(13) + Chr(10)
 
 n = 0
 
 addOn 1
 
 
 Text1.Text = Text1.Text & crlf & ct & " done"
  
End Sub

Sub addOn(wh)
 DoEvents
  saveN = n
  If wh = 1 Then st = 1 Else st = 0
  For newd = st To 9
    n = 10 * saveN + newd
    q = Int(n / wh): r = n - q * wh
    If r = 0 Then
      If wh = 10 Then
        uCt = 0: ReDim used(9)
        s$ = LTrim(Str(n))
        For i = 1 To Len(s)
          If used(Val(Mid(s, i, 1))) = 0 Then uCt = uCt + 1
          used(Val(Mid(s, i, 1))) = 1
        Next
        If uCt < 4 Then Text1.Text = Text1.Text & n & Str(uCt) & crlf
        ct = ct + 1
      Else
        addOn wh + 1
      End If
    End If
  Next
  n = saveN
End Sub


  Posted by Charlie on 2018-05-17 12:32:17
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 (21)
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