<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Digits in powers of 2</title>
	<atom:link href="http://www.johndcook.com/blog/2012/11/23/digits-in-powers-of-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.johndcook.com/blog/2012/11/23/digits-in-powers-of-2/</link>
	<description>John D. Cook</description>
	<lastBuildDate>Mon, 20 May 2013 13:14:55 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Which powers of 2 do not contain the digit 7? &#124; mathblag</title>
		<link>http://www.johndcook.com/blog/2012/11/23/digits-in-powers-of-2/comment-page-1/#comment-3638</link>
		<dc:creator>Which powers of 2 do not contain the digit 7? &#124; mathblag</dc:creator>
		<pubDate>Mon, 10 Dec 2012 01:31:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=12511#comment-3638</guid>
		<description><![CDATA[[...] interest in this question was inspired by a blog post by John D. Cook. Share this:PrintEmailMoreStumbleUponGoogle [...] ]]></description>
		<content:encoded><![CDATA[<p>[...] interest in this question was inspired by a blog post by John D. Cook. Share this:PrintEmailMoreStumbleUponGoogle [...] </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Radcliffe</title>
		<link>http://www.johndcook.com/blog/2012/11/23/digits-in-powers-of-2/comment-page-1/#comment-3637</link>
		<dc:creator>Dave Radcliffe</dc:creator>
		<pubDate>Sun, 09 Dec 2012 07:35:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=12511#comment-3637</guid>
		<description><![CDATA[I suggest that you keep only the last 60 digits or so, by setting N = (N*2) % (10**60) after each iteration. If there is no 7 in the last 60 digits, then check the last 200 digits by using pow(2, n, 10**200). If that also fails then try the last 400 digits, etc. Only compute the entire decimal expansion as a last resort. You can check exponents into the billions with this approach.]]></description>
		<content:encoded><![CDATA[<p>I suggest that you keep only the last 60 digits or so, by setting N = (N*2) % (10**60) after each iteration. If there is no 7 in the last 60 digits, then check the last 200 digits by using pow(2, n, 10**200). If that also fails then try the last 400 digits, etc. Only compute the entire decimal expansion as a last resort. You can check exponents into the billions with this approach.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Visto nel Web &#8211; 54 &#171; Ok, panico</title>
		<link>http://www.johndcook.com/blog/2012/11/23/digits-in-powers-of-2/comment-page-1/#comment-3636</link>
		<dc:creator>Visto nel Web &#8211; 54 &#171; Ok, panico</dc:creator>
		<pubDate>Sun, 25 Nov 2012 08:41:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=12511#comment-3636</guid>
		<description><![CDATA[[...] Digits in powers of 2 per Bit3Lux ::: The Endeavour [...] ]]></description>
		<content:encoded><![CDATA[<p>[...] Digits in powers of 2 per Bit3Lux ::: The Endeavour [...] </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Feuer</title>
		<link>http://www.johndcook.com/blog/2012/11/23/digits-in-powers-of-2/comment-page-1/#comment-3635</link>
		<dc:creator>David Feuer</dc:creator>
		<pubDate>Sat, 24 Nov 2012 20:01:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=12511#comment-3635</guid>
		<description><![CDATA[I think you can get much faster code by giving up on using built-in (binary) numbers altogether. Just do all the arithmetic in (binary coded) decimal. Instead of calculating 2**n each time, store an array of, say, 40000 digits, and double it on each iteration, scanning for sevens as you do. I believe this should be much faster than doing an expensive binary-to-decimal conversion each time.

Note: there are all sorts of tricks I don&#039;t know to make BCD arithmetic faster, if you need.]]></description>
		<content:encoded><![CDATA[<p>I think you can get much faster code by giving up on using built-in (binary) numbers altogether. Just do all the arithmetic in (binary coded) decimal. Instead of calculating 2**n each time, store an array of, say, 40000 digits, and double it on each iteration, scanning for sevens as you do. I believe this should be much faster than doing an expensive binary-to-decimal conversion each time.</p>
<p>Note: there are all sorts of tricks I don&#8217;t know to make BCD arithmetic faster, if you need.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: robru</title>
		<link>http://www.johndcook.com/blog/2012/11/23/digits-in-powers-of-2/comment-page-1/#comment-3634</link>
		<dc:creator>robru</dc:creator>
		<pubDate>Sat, 24 Nov 2012 00:06:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=12511#comment-3634</guid>
		<description><![CDATA[TomF: You beat me to it. Not only is str() simpler than digits(), it is significantly faster, too. Here are some benchmarks:

&lt;code&gt;
$ time python digits.py
71 2361183241434822606848

real    0m48.748s
user    0m48.712s
sys     0m0.000s

$ time python str.py
71 2361183241434822606848

real    0m0.575s
user    0m0.564s
sys     0m0.008s
&lt;/code&gt;]]></description>
		<content:encoded><![CDATA[<p>TomF: You beat me to it. Not only is str() simpler than digits(), it is significantly faster, too. Here are some benchmarks:</p>
<p><code><br />
$ time python digits.py<br />
71 2361183241434822606848</p>
<p>real    0m48.748s<br />
user    0m48.712s<br />
sys     0m0.000s</p>
<p>$ time python str.py<br />
71 2361183241434822606848</p>
<p>real    0m0.575s<br />
user    0m0.564s<br />
sys     0m0.008s<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.johndcook.com/blog/2012/11/23/digits-in-powers-of-2/comment-page-1/#comment-3633</link>
		<dc:creator>John</dc:creator>
		<pubDate>Fri, 23 Nov 2012 17:38:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=12511#comment-3633</guid>
		<description><![CDATA[lvps1000vm: Thanks for the code.

I edited your comment to change your &quot;code&quot; tag to a &quot;pre&quot; tag and that restored your indentation.]]></description>
		<content:encoded><![CDATA[<p>lvps1000vm: Thanks for the code.</p>
<p>I edited your comment to change your &#8220;code&#8221; tag to a &#8220;pre&#8221; tag and that restored your indentation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TomF</title>
		<link>http://www.johndcook.com/blog/2012/11/23/digits-in-powers-of-2/comment-page-1/#comment-3632</link>
		<dc:creator>TomF</dc:creator>
		<pubDate>Fri, 23 Nov 2012 17:38:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=12511#comment-3632</guid>
		<description><![CDATA[Implementation detail: this really only needs four lines:
for i in xrange(71, 10000):
    p = 2**i
    if &#039;7&#039; not in str(p):
        print i, p

If you really need the SET of digits in x: set(str(x)).]]></description>
		<content:encoded><![CDATA[<p>Implementation detail: this really only needs four lines:<br />
for i in xrange(71, 10000):<br />
    p = 2**i<br />
    if &#8217;7&#8242; not in str(p):<br />
        print i, p</p>
<p>If you really need the SET of digits in x: set(str(x)).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lvps1000vm</title>
		<link>http://www.johndcook.com/blog/2012/11/23/digits-in-powers-of-2/comment-page-1/#comment-3631</link>
		<dc:creator>lvps1000vm</dc:creator>
		<pubDate>Fri, 23 Nov 2012 15:24:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=12511#comment-3631</guid>
		<description><![CDATA[Oh, the previous comment lost the identation. I was just checking that all digits are present and not just 7. After 168 doesn&#039;t appear to return more results.]]></description>
		<content:encoded><![CDATA[<p>Oh, the previous comment lost the identation. I was just checking that all digits are present and not just 7. After 168 doesn&#8217;t appear to return more results.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lvps1000vm</title>
		<link>http://www.johndcook.com/blog/2012/11/23/digits-in-powers-of-2/comment-page-1/#comment-3630</link>
		<dc:creator>lvps1000vm</dc:creator>
		<pubDate>Fri, 23 Nov 2012 15:21:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=12511#comment-3630</guid>
		<description><![CDATA[In fact, 168 looks like the greatest number to miss &lt;i&gt;any&lt;/i&gt; digit

&lt;pre&gt;
def digits(n):
    s = set()
    while n &gt; 0:
        s.add(n%10)
        n /= 10
        if len(s) == 10:
            break
    return s

for i in range(100, 100000):
    p = 2**i
    if len(digits(p)) &lt; 10:
        print i, len(digits(p))
    if i % 10000 == 0:
        print &quot;checked&quot;,i
&lt;/pre&gt;

I conjecture: maybe 7 is interesting because the rest are all proven.]]></description>
		<content:encoded><![CDATA[<p>In fact, 168 looks like the greatest number to miss <i>any</i> digit</p>
<pre>
def digits(n):
    s = set()
    while n &gt; 0:
        s.add(n%10)
        n /= 10
        if len(s) == 10:
            break
    return s

for i in range(100, 100000):
    p = 2**i
    if len(digits(p)) &lt; 10:
        print i, len(digits(p))
    if i % 10000 == 0:
        print &quot;checked&quot;,i
</pre>
<p>I conjecture: maybe 7 is interesting because the rest are all proven.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yves Langlois</title>
		<link>http://www.johndcook.com/blog/2012/11/23/digits-in-powers-of-2/comment-page-1/#comment-3629</link>
		<dc:creator>Yves Langlois</dc:creator>
		<pubDate>Fri, 23 Nov 2012 13:51:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.johndcook.com/blog/?p=12511#comment-3629</guid>
		<description><![CDATA[Why specifically the conjecture is about only 7?

5 doesn&#039;t seem to be there either.
9 is not present for i=108 but always after until 10000.]]></description>
		<content:encoded><![CDATA[<p>Why specifically the conjecture is about only 7?</p>
<p>5 doesn&#8217;t seem to be there either.<br />
9 is not present for i=108 but always after until 10000.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
