<?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: Large Number Arithmetic</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2009/01/12/large-number-arithmetic/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2009/01/12/large-number-arithmetic/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Wed, 08 Feb 2012 23:58:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: fzz</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/12/large-number-arithmetic/#comment-37332</link>
		<dc:creator>fzz</dc:creator>
		<pubDate>Sun, 18 Jan 2009 08:39:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1941#comment-37332</guid>
		<description>&lt;p&gt;Grrr! The sum of the decimal digits of 2^N for N from 2 to 1024 is given by INDEX(A:A,3*N).&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Grrr! The sum of the decimal digits of 2^N for N from 2 to 1024 is given by INDEX(A:A,3*N).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fzz</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/12/large-number-arithmetic/#comment-37331</link>
		<dc:creator>fzz</dc:creator>
		<pubDate>Sun, 18 Jan 2009 08:37:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1941#comment-37331</guid>
		<description>&lt;p&gt;All the Euler problems lend themselves to solutions in functional programming languages, so Excel itself should be sufficient to solve all of them. For example, #16, the sum of the digits of the base 10 representation of 2^1000. Since INT(LOG10(2^1000)) = 301, this will require 301 decimal places to the left of the decimal point.&lt;/p&gt;
&lt;p&gt;A4  2&lt;br&gt;
A6  =SUM(A7:IP8)&lt;br&gt;
A7  =MOD(A4*2,10)&lt;br&gt;
B7  =MOD(B4*2,10)+INT(A4/5)  fill into C7:IP7&lt;br&gt;
A8  =MOD(A5*2,10)+INT(IP4/5)&lt;br&gt;
B8  =MOD(B5*2,10)+INT(A5/5)  fill into C8:IP8&lt;/p&gt;
&lt;p&gt;Copy A6:IP8, paste into A9. Copy A6:IP11, paste into A12. That is, double the copy/paste range each time, so reach 2^1024 after 10 copy/paste operations.&lt;/p&gt;
&lt;p&gt;The sum of the decimal digits of 2^N (1&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>All the Euler problems lend themselves to solutions in functional programming languages, so Excel itself should be sufficient to solve all of them. For example, #16, the sum of the digits of the base 10 representation of 2^1000. Since INT(LOG10(2^1000)) = 301, this will require 301 decimal places to the left of the decimal point.</p>
<p>A4  2<br />
A6  =SUM(A7:IP8)<br />
A7  =MOD(A4*2,10)<br />
B7  =MOD(B4*2,10)+INT(A4/5)  fill into C7:IP7<br />
A8  =MOD(A5*2,10)+INT(IP4/5)<br />
B8  =MOD(B5*2,10)+INT(A5/5)  fill into C8:IP8</p>
<p>Copy A6:IP8, paste into A9. Copy A6:IP11, paste into A12. That is, double the copy/paste range each time, so reach 2^1024 after 10 copy/paste operations.</p>
<p>The sum of the decimal digits of 2^N (1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/12/large-number-arithmetic/#comment-37320</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Sat, 17 Jan 2009 17:02:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1941#comment-37320</guid>
		<description>&lt;p&gt;Hi Doug -&lt;/p&gt;
&lt;p&gt;Re:  #97.  Thank you.  Taught me two things.  1.  RIGHT() works on doubles.  I thought it only worked on strings and variants.  I&#039;ve been doing some unnecessary type changes, and 2. RIGHT() and * are commutative. They never taught me that in arithmetic ;-)&lt;/p&gt;
&lt;p&gt;...mrt&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi Doug -</p>
<p>Re:  #97.  Thank you.  Taught me two things.  1.  RIGHT() works on doubles.  I thought it only worked on strings and variants.  I&#8217;ve been doing some unnecessary type changes, and 2. RIGHT() and * are commutative. They never taught me that in arithmetic <img src='http://www.dailydoseofexcel.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>&#8230;mrt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Jenkins</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/12/large-number-arithmetic/#comment-37253</link>
		<dc:creator>Doug Jenkins</dc:creator>
		<pubDate>Thu, 15 Jan 2009 12:17:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1941#comment-37253</guid>
		<description>&lt;p&gt;&quot;Doug: #16, #20, #25 for starters.&quot;&lt;/p&gt;
&lt;p&gt;OK, I forgot that I did in fact write specific routines for those questions that in effect used large number arithmatic.  I set up big arrays and did it one digit at a time.  Not very efficient, but they worked well within the allotted time.&lt;/p&gt;
&lt;p&gt;Here&#039;s the code for the sum of the digits in 100! for instance (which takes less than a second):&lt;/p&gt;
&lt;p&gt;Function SumFact(num)&lt;br&gt;
Dim DigitA(1 To 1000) As Long, NumDigits As Long, i As Long, j As Long, carry As Long&lt;br&gt;
Dim k As Long, x As Long, Facts As String&lt;/p&gt;
&lt;p&gt;NumDigits = 1&lt;br&gt;
DigitA(1) = 1&lt;/p&gt;
&lt;p&gt;For i = 2 To num&lt;br&gt;
carry = 0&lt;br&gt;
For j = 1 To NumDigits&lt;br&gt;
DigitA(j) = DigitA(j) * i + carry&lt;br&gt;
If DigitA(j) .GT. 9 Then&lt;br&gt;
carry = Int(DigitA(j) / 10)&lt;br&gt;
DigitA(j) = DigitA(j) - carry * 10&lt;/p&gt;
&lt;p&gt;If j = NumDigits Then&lt;br&gt;
DigitA(j + 1) = carry&lt;br&gt;
NumDigits = NumDigits + 1&lt;br&gt;
If carry .GT. 9 Then&lt;br&gt;
x = Int(Log(carry) / Log(10))&lt;br&gt;
For k = j + 1 To j + x&lt;br&gt;
DigitA(k) = carry - Int(carry / 10) * 10&lt;br&gt;
carry = Int(carry / 10)&lt;br&gt;
NumDigits = NumDigits + 1&lt;br&gt;
Next k&lt;br&gt;
DigitA(NumDigits) = carry&lt;br&gt;
End If&lt;br&gt;
End If&lt;br&gt;
Else&lt;br&gt;
carry = 0&lt;br&gt;
End If&lt;br&gt;
Next j&lt;br&gt;
Next i&lt;br&gt;
For i = NumDigits To 1 Step -1&lt;br&gt;
SumFact = SumFact + DigitA(i)&lt;br&gt;
Next i&lt;/p&gt;
&lt;p&gt;End Function&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>&#8220;Doug: #16, #20, #25 for starters.&#8221;</p>
<p>OK, I forgot that I did in fact write specific routines for those questions that in effect used large number arithmatic.  I set up big arrays and did it one digit at a time.  Not very efficient, but they worked well within the allotted time.</p>
<p>Here&#8217;s the code for the sum of the digits in 100! for instance (which takes less than a second):</p>
<p>Function SumFact(num)<br />
Dim DigitA(1 To 1000) As Long, NumDigits As Long, i As Long, j As Long, carry As Long<br />
Dim k As Long, x As Long, Facts As String</p>
<p>NumDigits = 1<br />
DigitA(1) = 1</p>
<p>For i = 2 To num<br />
carry = 0<br />
For j = 1 To NumDigits<br />
DigitA(j) = DigitA(j) * i + carry<br />
If DigitA(j) .GT. 9 Then<br />
carry = Int(DigitA(j) / 10)<br />
DigitA(j) = DigitA(j) &#8211; carry * 10</p>
<p>If j = NumDigits Then<br />
DigitA(j + 1) = carry<br />
NumDigits = NumDigits + 1<br />
If carry .GT. 9 Then<br />
x = Int(Log(carry) / Log(10))<br />
For k = j + 1 To j + x<br />
DigitA(k) = carry &#8211; Int(carry / 10) * 10<br />
carry = Int(carry / 10)<br />
NumDigits = NumDigits + 1<br />
Next k<br />
DigitA(NumDigits) = carry<br />
End If<br />
End If<br />
Else<br />
carry = 0<br />
End If<br />
Next j<br />
Next i<br />
For i = NumDigits To 1 Step -1<br />
SumFact = SumFact + DigitA(i)<br />
Next i</p>
<p>End Function</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Jenkins</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/12/large-number-arithmetic/#comment-37252</link>
		<dc:creator>Doug Jenkins</dc:creator>
		<pubDate>Thu, 15 Jan 2009 12:16:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1941#comment-37252</guid>
		<description>&lt;p&gt;&gt;&gt;&lt;br&gt;
Doug: #16, #20, #25 for starters.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>&gt;&gt;<br />
Doug: #16, #20, #25 for starters.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mpemba</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/12/large-number-arithmetic/#comment-37249</link>
		<dc:creator>Mpemba</dc:creator>
		<pubDate>Thu, 15 Jan 2009 11:22:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1941#comment-37249</guid>
		<description>&lt;p&gt;&gt;So far I&#039;ve managed to solve all the questions&lt;br&gt;
&gt;I&#039;ve tackled using only doubles or non-arithmetic use of strings&lt;/p&gt;
&lt;p&gt;The main problems for me have been in matrix operations where the precision is an issue.&lt;br&gt;
Foxes bigmatrix operations solve this limitation.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>&gt;So far I&#8217;ve managed to solve all the questions<br />
&gt;I&#8217;ve tackled using only doubles or non-arithmetic use of strings</p>
<p>The main problems for me have been in matrix operations where the precision is an issue.<br />
Foxes bigmatrix operations solve this limitation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tushar Mehta</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/12/large-number-arithmetic/#comment-37247</link>
		<dc:creator>Tushar Mehta</dc:creator>
		<pubDate>Thu, 15 Jan 2009 09:44:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1941#comment-37247</guid>
		<description>&lt;p&gt;Doug: #16, #20, #25 for starters.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Doug: #16, #20, #25 for starters.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Jenkins</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/12/large-number-arithmetic/#comment-37244</link>
		<dc:creator>Doug Jenkins</dc:creator>
		<pubDate>Thu, 15 Jan 2009 07:16:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1941#comment-37244</guid>
		<description>&lt;p&gt;Michael - No 97 was pretty easy (although it took me way longer than it should have). I just successively muliplied by 2, 7,830,456 times, discarding the left hand digits whenever there were more than 10, then multiplied by 20,000, 8,000, and 433, discarding excess digits, added the results then added 1.  I used a double rather than long, because a long doesn&#039;t give enough digits.&lt;/p&gt;
&lt;p&gt;I started off doing it in a spreadsheet (in XL 2007), in 7 stages.  It works, but it&#039;s very slow.&lt;/p&gt;
&lt;p&gt;104 might be a bit more difficult, because you need the start digits of a long number.  I&#039;ll have a think about that one later.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Michael &#8211; No 97 was pretty easy (although it took me way longer than it should have). I just successively muliplied by 2, 7,830,456 times, discarding the left hand digits whenever there were more than 10, then multiplied by 20,000, 8,000, and 433, discarding excess digits, added the results then added 1.  I used a double rather than long, because a long doesn&#8217;t give enough digits.</p>
<p>I started off doing it in a spreadsheet (in XL 2007), in 7 stages.  It works, but it&#8217;s very slow.</p>
<p>104 might be a bit more difficult, because you need the start digits of a long number.  I&#8217;ll have a think about that one later.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/12/large-number-arithmetic/#comment-37235</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Thu, 15 Jan 2009 01:34:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1941#comment-37235</guid>
		<description>&lt;p&gt;Doug -&lt;br&gt;
#104?  Broke AddAsStrings..&lt;/p&gt;
&lt;p&gt;The Fibonacci sequence is defined by the recurrence relation:&lt;/p&gt;
&lt;p&gt;    F_(n) = F_(n-1) + F_(n-2), where F_(1) = 1 and F_(2) = 1.&lt;/p&gt;
&lt;p&gt;It turns out that F_(541), which contains 113 digits, is the first Fibonacci number for which the last nine digits are 1-9 pandigital (contain all the digits 1 to 9, but not necessarily in order). And F_(2749), which contains 575 digits, is the first Fibonacci number for which the first nine digits are 1-9 pandigital.&lt;/p&gt;
&lt;p&gt;Given that F_(k) is the first Fibonacci number for which the first nine digits AND the last nine digits are 1-9 pandigital, find k.&lt;/p&gt;
&lt;p&gt;...mrt&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Doug -<br />
#104?  Broke AddAsStrings..</p>
<p>The Fibonacci sequence is defined by the recurrence relation:</p>
<p>    F_(n) = F_(n-1) + F_(n-2), where F_(1) = 1 and F_(2) = 1.</p>
<p>It turns out that F_(541), which contains 113 digits, is the first Fibonacci number for which the last nine digits are 1-9 pandigital (contain all the digits 1 to 9, but not necessarily in order). And F_(2749), which contains 575 digits, is the first Fibonacci number for which the first nine digits are 1-9 pandigital.</p>
<p>Given that F_(k) is the first Fibonacci number for which the first nine digits AND the last nine digits are 1-9 pandigital, find k.</p>
<p>&#8230;mrt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/01/12/large-number-arithmetic/#comment-37234</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Thu, 15 Jan 2009 01:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1941#comment-37234</guid>
		<description>&lt;p&gt;Doug -&lt;/p&gt;
&lt;p&gt;#97?&lt;/p&gt;
&lt;p&gt;The first known prime found to exceed one million digits was discovered in 1999, and is a Mersenne prime of the form 2^(6972593)-1; it contains exactly 2,098,960 digits. Subsequently other Mersenne primes, of the form 2^(p)-1, have been found which contain more digits.&lt;/p&gt;
&lt;p&gt;However, in 2004 there was found a massive non-Mersenne prime which contains 2,357,207 digits: 28433×2^(7830457)+1.&lt;/p&gt;
&lt;p&gt;Find the last ten digits of this prime number.&lt;/p&gt;
&lt;p&gt;...mrt&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Doug -</p>
<p>#97?</p>
<p>The first known prime found to exceed one million digits was discovered in 1999, and is a Mersenne prime of the form 2^(6972593)-1; it contains exactly 2,098,960 digits. Subsequently other Mersenne primes, of the form 2^(p)-1, have been found which contain more digits.</p>
<p>However, in 2004 there was found a massive non-Mersenne prime which contains 2,357,207 digits: 28433×2^(7830457)+1.</p>
<p>Find the last ten digits of this prime number.</p>
<p>&#8230;mrt</p>
]]></content:encoded>
	</item>
</channel>
</rss>

