What is the largest integer n < 1 0 0 0 such that the decimal representation of 2 n does not contain 0 as a digit?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Nice solution! +1
My Python program is as follows:
1 2 3 4 5 6 7 8 9 10 |
|
Good, standard solution.
is there alternative way to do it without Python program ?
1 2 3 4 5 |
|
Any particular reason to initialize
lar
to
None
than zero?
Any idea if there is a larger power of 2 which doesn't contain a 0?
1 2 3 4 5 |
|
VB.Net Solution:
Make sure to import System.Numerics.
Sub Main()
For n = 1000 To 1 Step -1
If Not ContainsZero(BigInteger.Pow(2, n)) Then
Console.WriteLine(n)
End If
Next
Console.ReadLine()
End Sub
Function ContainsZero(Number As BigInteger) As Boolean
Dim a As String = Number.ToString
For n = 0 To a.Length - 1
If a(n) = "0" Then
Return True
End If
Next
Return False
End Function
Thank you for your solution! =D
My
python 2.7
program:
for i in range(1000):
k=2**i
if "0" in str(k):
pass
else:
print i
My colourful layman's solution :
yCheck for occurrences of zero digits in all powers of two less than one thousand, and avoid exponentiating individual powers of two, which is expensive.
Problem Loading...
Note Loading...
Set Loading...
Python 3.3: