<?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: Euler Problem 104</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2009/03/22/euler-problem-104/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2009/03/22/euler-problem-104/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Thu, 09 Feb 2012 19:28:40 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Doug Jenkins</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/03/22/euler-problem-104/#comment-38644</link>
		<dc:creator>Doug Jenkins</dc:creator>
		<pubDate>Tue, 24 Mar 2009 08:01:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=2276#comment-38644</guid>
		<description>&lt;p&gt;I started off generationg the ends of the fibonacci numbers on the spreadsheet, and checking them with a UDF.  It works, but it would be very slow to find the resullt required, and would need to be done in stages when using pre-2007 versions, so I ended up writing some VBA to generate the numbers as well.  I started off using strings to check for pandigitals, but converted to the routine below, which uses doubles, and strips off one digit at a time by dividing by 10.  It stops if it finds a repeated digit or zero.  The values for the left hand end may include a decimal point in the first nine digits, so the function multiplies any left hand value less than 1000000000 by 10^(9-k), where k is the number of digits before the decimal point. The right hand values always start with 9 digits, so a k of less than 9 indicates one or more leading zeroes.    &lt;/p&gt;
&lt;p&gt;Solution time a shade over 1 second.  I thought I&#039;d get it under 1 second by running in XL 2000, but it was almost exactly the same time (to my surprise).&lt;/p&gt;
&lt;p&gt;[VB}&lt;br&gt;
Function pandigital(ByVal val As Double, LorR As String) As Boolean&lt;br&gt;
    Dim DigitA(1 To 9) As Long, i As Long, j As Long, k As Long, CheckVal As Double, NCheckval As Double&lt;/p&gt;
&lt;p&gt;   k = (Log(val) / Log(10))&lt;br&gt;
    CheckVal = val&lt;/p&gt;
&lt;p&gt;    If k .NE. 9 Then&lt;br&gt;
        If LorR = &quot;R&quot; Then&lt;br&gt;
            pandigital = False&lt;br&gt;
            Exit Function&lt;br&gt;
        Else&lt;br&gt;
            CheckVal = val * 10 ^ (9 - k)&lt;br&gt;
        End If&lt;br&gt;
    End If&lt;/p&gt;
&lt;p&gt;    For i = 1 To 9&lt;br&gt;
        NCheckval = Int(CheckVal / 10)&lt;br&gt;
        j = CheckVal - NCheckval * 10&lt;br&gt;
        CheckVal = NCheckval&lt;/p&gt;
&lt;p&gt;        If j = 0 Or j .GT. 9 Then&lt;br&gt;
            pandigital = False&lt;br&gt;
            Exit Function&lt;br&gt;
        End If&lt;/p&gt;
&lt;p&gt;        If DigitA(j) = 1 Then&lt;br&gt;
            pandigital = False&lt;br&gt;
            Exit Function&lt;br&gt;
        Else&lt;br&gt;
            DigitA(j) = 1&lt;br&gt;
        End If&lt;/p&gt;
&lt;p&gt;    Next i&lt;br&gt;
    pandigital = True&lt;/p&gt;
&lt;p&gt;End Function&lt;br&gt;
[VB]&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I started off generationg the ends of the fibonacci numbers on the spreadsheet, and checking them with a UDF.  It works, but it would be very slow to find the resullt required, and would need to be done in stages when using pre-2007 versions, so I ended up writing some VBA to generate the numbers as well.  I started off using strings to check for pandigitals, but converted to the routine below, which uses doubles, and strips off one digit at a time by dividing by 10.  It stops if it finds a repeated digit or zero.  The values for the left hand end may include a decimal point in the first nine digits, so the function multiplies any left hand value less than 1000000000 by 10^(9-k), where k is the number of digits before the decimal point. The right hand values always start with 9 digits, so a k of less than 9 indicates one or more leading zeroes.    </p>
<p>Solution time a shade over 1 second.  I thought I&#8217;d get it under 1 second by running in XL 2000, but it was almost exactly the same time (to my surprise).</p>
<p>[VB}<br />
Function pandigital(ByVal val As Double, LorR As String) As Boolean<br />
    Dim DigitA(1 To 9) As Long, i As Long, j As Long, k As Long, CheckVal As Double, NCheckval As Double</p>
<p>   k = (Log(val) / Log(10))<br />
    CheckVal = val</p>
<p>    If k .NE. 9 Then<br />
        If LorR = "R" Then<br />
            pandigital = False<br />
            Exit Function<br />
        Else<br />
            CheckVal = val * 10 ^ (9 - k)<br />
        End If<br />
    End If</p>
<p>    For i = 1 To 9<br />
        NCheckval = Int(CheckVal / 10)<br />
        j = CheckVal - NCheckval * 10<br />
        CheckVal = NCheckval</p>
<p>        If j = 0 Or j .GT. 9 Then<br />
            pandigital = False<br />
            Exit Function<br />
        End If</p>
<p>        If DigitA(j) = 1 Then<br />
            pandigital = False<br />
            Exit Function<br />
        Else<br />
            DigitA(j) = 1<br />
        End If</p>
<p>    Next i<br />
    pandigital = True</p>
<p>End Function<br />
[VB]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/03/22/euler-problem-104/#comment-38636</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Mon, 23 Mar 2009 18:03:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=2276#comment-38636</guid>
		<description>&lt;p&gt;Hi Ross -&lt;/p&gt;
&lt;p&gt;I could never get those BigNum routines to work.  They are called with 3 parameters, with the 3rd one not optional.  I could never decipher why you needed three parameters to operate on two numbers (or strings).  Still can&#039;t.  The author did not assign any meaningful names to his variables!&lt;/p&gt;
&lt;p&gt;And not being able to load the form made me unable to check out anything. &lt;/p&gt;
&lt;p&gt;Is it straight forward?  I suppose somewhat.  I get the additions certainly, and The Foxes website walks through a large multiplication at&lt;br&gt;
&lt;a href=&quot;http://digilander.libero.it/foxes/MultiPrecision.htm#Packet&quot; rel=&quot;nofollow&quot;&gt;http://digilander.libero.it/foxes/MultiPrecision.htm#Packet&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I&#039;d find it more straight forward for understanding the whole process if both their multiplier and their multiplicand had to be packetized. &lt;/p&gt;
&lt;p&gt;...mrt&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi Ross -</p>
<p>I could never get those BigNum routines to work.  They are called with 3 parameters, with the 3rd one not optional.  I could never decipher why you needed three parameters to operate on two numbers (or strings).  Still can&#8217;t.  The author did not assign any meaningful names to his variables!</p>
<p>And not being able to load the form made me unable to check out anything. </p>
<p>Is it straight forward?  I suppose somewhat.  I get the additions certainly, and The Foxes website walks through a large multiplication at<br />
<a href="http://digilander.libero.it/foxes/MultiPrecision.htm#Packet" rel="nofollow">http://digilander.libero.it/foxes/MultiPrecision.htm#Packet</a></p>
<p>I&#8217;d find it more straight forward for understanding the whole process if both their multiplier and their multiplicand had to be packetized. </p>
<p>&#8230;mrt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ross</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/03/22/euler-problem-104/#comment-38634</link>
		<dc:creator>Ross</dc:creator>
		<pubDate>Mon, 23 Mar 2009 15:33:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=2276#comment-38634</guid>
		<description>&lt;p&gt;Hi again,&lt;br&gt;
one other thing, what was wrong with the BigNum Code you linked to before? Did it have a size limit?&lt;br&gt;
Thanks&lt;br&gt;
Ross&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi again,<br />
one other thing, what was wrong with the BigNum Code you linked to before? Did it have a size limit?<br />
Thanks<br />
Ross</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ross</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/03/22/euler-problem-104/#comment-38633</link>
		<dc:creator>Ross</dc:creator>
		<pubDate>Mon, 23 Mar 2009 15:31:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=2276#comment-38633</guid>
		<description>&lt;p&gt;Hi Michael, &lt;/p&gt;
&lt;p&gt;Interesting stuff, I spent a little bit of time reading up on this, this PM. There is an addin which claims to work with over 2 billion digits, so there you go! (the link to the site is at the bottom of Tushar&#039;s pages)&lt;/p&gt;
&lt;p&gt;Is it not a relatively rival task to just use 2 string in stead of one? (looking at Tushar&#039;s code away). Having said that I am extreamly confident that your understanding of this is much much much much^10000! better than mine, and there is a reason why this is not straight forward?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi Michael, </p>
<p>Interesting stuff, I spent a little bit of time reading up on this, this PM. There is an addin which claims to work with over 2 billion digits, so there you go! (the link to the site is at the bottom of Tushar&#8217;s pages)</p>
<p>Is it not a relatively rival task to just use 2 string in stead of one? (looking at Tushar&#8217;s code away). Having said that I am extreamly confident that your understanding of this is much much much much^10000! better than mine, and there is a reason why this is not straight forward?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/03/22/euler-problem-104/#comment-38618</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Sun, 22 Mar 2009 23:23:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=2276#comment-38618</guid>
		<description>&lt;p&gt;Hi Ross -&lt;/p&gt;
&lt;p&gt;The Euler problems are famous for asking for answers that require precision longer than 32 bits.  Math done that way can be done on strings, and the answers are strings.  For instance, AddAsStrings takes two numbers and adds them in columns, with carrys, from the right side, just as you did in elementary school.  I do it one column at a time, Tushar does many at a time (his is much, much the faster), but for both of us, the result is a string representation of the number.  The Foxes team addin can do math up to 250 significant digits in several hundred esoteric functions.  All of it is string manipulation.&lt;/p&gt;
&lt;p&gt;The problem here is that the Fibonacci number of the Answer is longer than Excel can handle as a string, and larger than Excel can handle as a double, and we need to be accurate at the front and the back.  The middle is of no consequence to Euler ;-).  If you look up the Excel limit for string size, it&#039;s about 64K characters.  The length of the answer is longer than that, and we need to look at it&#039;s first nine digits in the doubles, and its last nine digits in the longs.  If there is a LargeNumber API for us, I&#039;ve not stumbled across it.&lt;/p&gt;
&lt;p&gt;...mrt&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi Ross -</p>
<p>The Euler problems are famous for asking for answers that require precision longer than 32 bits.  Math done that way can be done on strings, and the answers are strings.  For instance, AddAsStrings takes two numbers and adds them in columns, with carrys, from the right side, just as you did in elementary school.  I do it one column at a time, Tushar does many at a time (his is much, much the faster), but for both of us, the result is a string representation of the number.  The Foxes team addin can do math up to 250 significant digits in several hundred esoteric functions.  All of it is string manipulation.</p>
<p>The problem here is that the Fibonacci number of the Answer is longer than Excel can handle as a string, and larger than Excel can handle as a double, and we need to be accurate at the front and the back.  The middle is of no consequence to Euler <img src='http://www.dailydoseofexcel.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .  If you look up the Excel limit for string size, it&#8217;s about 64K characters.  The length of the answer is longer than that, and we need to look at it&#8217;s first nine digits in the doubles, and its last nine digits in the longs.  If there is a LargeNumber API for us, I&#8217;ve not stumbled across it.</p>
<p>&#8230;mrt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ross</title>
		<link>http://www.dailydoseofexcel.com/archives/2009/03/22/euler-problem-104/#comment-38617</link>
		<dc:creator>Ross</dc:creator>
		<pubDate>Sun, 22 Mar 2009 21:31:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=2276#comment-38617</guid>
		<description>&lt;p&gt;I wish was smart enough to understand this!!!Numbers that are to big to hold in a variable? is there no API you could use?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I wish was smart enough to understand this!!!Numbers that are to big to hold in a variable? is there no API you could use?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

