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

Home > Numbers
Decimal and Binary Representation (Posted on 2016-12-13) Difficulty: 3 of 5
Find a number with the following properties:
1. When expressed in decimal the number has each of the ten digits occuring exactly once.
2. When expressed in binary the number has the same number of 1s and 0s.

No leading zeros are allowed.

No Solution Yet Submitted by Brian Smith    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution (spoiler) Comment 3 of 3 |
There are 178,811 solutions. The lowest is

1023458769 or binary 111101000000001011110111010001

and the highest is

9876530214 or binary 1001001100101011111110010000100110

DefDbl A-Z
Dim crlf$


Private Sub Form_Load()
 Form1.Visible = True
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
 
 Open "decimal and binary representation.txt" For Output As #2
 
 s$ = "1234567890": h$ = s
 Do
   If Left(s, 1) > "0" Then
     n = Val(s)
     b$ = ""
     ct0 = 0: ct1 = 0
     Do
       DoEvents
       q = Int(n / 2): bindig = n - q * 2
       bd$ = LTrim(Str(bindig))
       n = q
       b = bd$ + b
       If bd = "1" Then ct1 = ct1 + 1 Else ct0 = ct0 + 1
     Loop Until n = 0
     If ct1 = ct0 Then
       Text1.Text = Text1.Text & s & "   " & b & crlf
       Print #2, s & "   " & b
     End If
   End If
   DoEvents
   permute s
 Loop Until s = h
 
 Close 2
 
 
 
 Text1.Text = Text1.Text & crlf & " done"
  
End Sub


  Posted by Charlie on 2016-12-14 10:23:49
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 (15)
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