 All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars  perplexus dot info  Decimal and Binary Representation (Posted on 2016-12-13) 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 Solution Yet Submitted by Brian Smith No Rating Comments: ( Back to comment list | You must be logged in to post comments.) 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\$

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:

 Search: Search body:
Forums (0)