<?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: Is this number prime?</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2005/06/30/is-this-number-prime/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2005/06/30/is-this-number-prime/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Thu, 09 Feb 2012 23:42:03 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Michael</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/06/30/is-this-number-prime/#comment-36996</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Thu, 08 Jan 2009 21:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1182#comment-36996</guid>
		<description>&lt;p&gt;The following array formula will test if a number is prime.&lt;/p&gt;
&lt;p&gt;=IF(A1=2,&quot;Prime&quot;,IF(AND((MOD(A1,ROW(INDIRECT(&quot;2:&quot;&amp;ROUNDUP(SQRT(A1),0))))0))=TRUE,&quot;Prime&quot;,&quot;Not Prime&quot;))&lt;/p&gt;
&lt;p&gt;You must press Ctrl Shift and Enter after you enter it.&lt;/p&gt;
&lt;p&gt;The formula relies on Excel&#039;s MOD function to calculate the remainder on every whole number divisor from 2 to&lt;br&gt;
the square root of the test number. If there is always a remainder then the number is prime.&lt;/p&gt;
&lt;p&gt;Excel&#039;s ability to calculate the remainder fails when the test number exceeds 268,435,455.&lt;/p&gt;
&lt;p&gt;You can download my workbook here:&lt;br&gt;
&lt;a href=&quot;http://www.excelexchange.com/prime_number_test.html&quot; rel=&quot;nofollow&quot;&gt;http://www.excelexchange.com/prime_number_test.html&lt;/a&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>The following array formula will test if a number is prime.</p>
<p>=IF(A1=2,&#8221;Prime&#8221;,IF(AND((MOD(A1,ROW(INDIRECT(&#8220;2:&#8221;&amp;ROUNDUP(SQRT(A1),0))))0))=TRUE,&#8221;Prime&#8221;,&#8221;Not Prime&#8221;))</p>
<p>You must press Ctrl Shift and Enter after you enter it.</p>
<p>The formula relies on Excel&#8217;s MOD function to calculate the remainder on every whole number divisor from 2 to<br />
the square root of the test number. If there is always a remainder then the number is prime.</p>
<p>Excel&#8217;s ability to calculate the remainder fails when the test number exceeds 268,435,455.</p>
<p>You can download my workbook here:<br />
<a href="http://www.excelexchange.com/prime_number_test.html" rel="nofollow">http://www.excelexchange.com/prime_number_test.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: surfie</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/06/30/is-this-number-prime/#comment-36048</link>
		<dc:creator>surfie</dc:creator>
		<pubDate>Wed, 12 Nov 2008 23:42:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1182#comment-36048</guid>
		<description>&lt;p&gt;That&#039;s odd - the &quot;&quot; that I included after the first &quot;A1? didn&#039;t print in my post (maybe that happened to fzz too). The other error (one too many right brackets after the second &quot;A1/2?) printed ok. Let&#039;s see what happens now...&lt;/p&gt;
&lt;p&gt;I would have liked to edit my first post, but can&#039;t see how.&lt;/p&gt;
&lt;p&gt;Btw, I just found and installed the freeware &quot;Morefunc&quot; collection of additional Excel worksheet functions. It includes &quot;PN.ISPRIME&quot;, which tests for primality. Works well, from what I&#039;ve seen.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>That&#8217;s odd &#8211; the &#8220;&#8221; that I included after the first &#8220;A1? didn&#8217;t print in my post (maybe that happened to fzz too). The other error (one too many right brackets after the second &#8220;A1/2?) printed ok. Let&#8217;s see what happens now&#8230;</p>
<p>I would have liked to edit my first post, but can&#8217;t see how.</p>
<p>Btw, I just found and installed the freeware &#8220;Morefunc&#8221; collection of additional Excel worksheet functions. It includes &#8220;PN.ISPRIME&#8221;, which tests for primality. Works well, from what I&#8217;ve seen.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: surfie</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/06/30/is-this-number-prime/#comment-36037</link>
		<dc:creator>surfie</dc:creator>
		<pubDate>Wed, 12 Nov 2008 17:37:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1182#comment-36037</guid>
		<description>&lt;p&gt;fzz&#039;s array formula results in an error, and without trying to understand it fully I&#039;ve come up with the following corrected version, which seems to work:-&lt;/p&gt;
&lt;p&gt;=IF(OR(A1INT(A1),A12,A1/2=INT(A1/2)),&quot;not prime&quot;,IF(OR(A1/(2*ROW($A$1:INDEX($A:$A,INT(SQRT(A1)/2)))+1)=INT(A1/(2*ROW($A$1:INDEX($A:$A,INT(SQRT(A1)/2)))+1))),&quot;not prime&quot;,&quot;prime&quot;))&lt;/p&gt;
&lt;p&gt;I found this old post on John Walkenbach&#039;s site &lt;a href=&quot;http://j-walk.com/ss/excel/eee/eee015.txt&quot; rel=&quot;nofollow&quot;&gt;http://j-walk.com/ss/excel/eee/eee015.txt&lt;/a&gt; (I have no idea at all about the formula&#039;s efficiency or reliability, other than to say that it worked quickly and accurately on the 50 or so tests I gave it):-&lt;/p&gt;
&lt;p&gt;by Bob Umlas&lt;/p&gt;
&lt;p&gt;This array formula returns TRUE if the number in cell A1 is a prime number. &lt;/p&gt;
&lt;p&gt;=OR(A1=2,A1=3,ISNA(MATCH(TRUE,A1/ROW(INDIRECT(&quot;2:&quot;&amp;INT(SQRT(A1))))=INT(A1/ROW(INDIRECT(&quot;2:&quot;&amp;INT(SQRT(A1))))),0)))&lt;/p&gt;
&lt;p&gt;Use it as a conditional formatting formula, with A1 as the active cell in the selection to be formatted.&lt;/p&gt;
&lt;p&gt;Here&#039;s how Bob&#039;s amazing formula works. In a nutshell, the number is divided by all potential prime factors, and the resulting array is tested to see whether it contains a whole number. If is does, you have a prime&lt;br&gt;
number. A limitation of this formula is that it cannot test numbers that are greater than 65535^2. This is due to the array size constraint in Excel 97/2000.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>fzz&#8217;s array formula results in an error, and without trying to understand it fully I&#8217;ve come up with the following corrected version, which seems to work:-</p>
<p>=IF(OR(A1INT(A1),A12,A1/2=INT(A1/2)),&#8221;not prime&#8221;,IF(OR(A1/(2*ROW($A$1:INDEX($A:$A,INT(SQRT(A1)/2)))+1)=INT(A1/(2*ROW($A$1:INDEX($A:$A,INT(SQRT(A1)/2)))+1))),&#8221;not prime&#8221;,&#8221;prime&#8221;))</p>
<p>I found this old post on John Walkenbach&#8217;s site <a href="http://j-walk.com/ss/excel/eee/eee015.txt" rel="nofollow">http://j-walk.com/ss/excel/eee/eee015.txt</a> (I have no idea at all about the formula&#8217;s efficiency or reliability, other than to say that it worked quickly and accurately on the 50 or so tests I gave it):-</p>
<p>by Bob Umlas</p>
<p>This array formula returns TRUE if the number in cell A1 is a prime number. </p>
<p>=OR(A1=2,A1=3,ISNA(MATCH(TRUE,A1/ROW(INDIRECT(&#8220;2:&#8221;&amp;INT(SQRT(A1))))=INT(A1/ROW(INDIRECT(&#8220;2:&#8221;&amp;INT(SQRT(A1))))),0)))</p>
<p>Use it as a conditional formatting formula, with A1 as the active cell in the selection to be formatted.</p>
<p>Here&#8217;s how Bob&#8217;s amazing formula works. In a nutshell, the number is divided by all potential prime factors, and the resulting array is tested to see whether it contains a whole number. If is does, you have a prime<br />
number. A limitation of this formula is that it cannot test numbers that are greater than 65535^2. This is due to the array size constraint in Excel 97/2000.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fzz</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/06/30/is-this-number-prime/#comment-34798</link>
		<dc:creator>fzz</dc:creator>
		<pubDate>Mon, 15 Sep 2008 20:42:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1182#comment-34798</guid>
		<description>&lt;p&gt;Chip&#039;s approach is very inefficient and unreliable.&lt;/p&gt;
&lt;p&gt;First, 2 is the only even prime number. No prime number can have an even even factor less than itself. Second, if a number is nonprime, it&#039;ll have a factor &gt; 1 and  2^29. Very unwise to use Excel&#039;s MOD in any formula involving factorization of arbitrary numbers.&lt;/p&gt;
&lt;p&gt;So longer but more efficient to use&lt;/p&gt;
&lt;p&gt;=IF(OR(A1INT(A1),A12,A1/2=INT(A1/2))),&quot;not prime&quot;,&lt;br&gt;
IF(OR(A1/(2*ROW($A$1:INDEX($A:$A,INT(SQRT(A1)/2)))+1)&lt;br&gt;
=INT(A1/(2*ROW($A$1:INDEX($A:$A,INT(SQRT(A1)/2)))+1))),&lt;br&gt;
&quot;not prime&quot;,&quot;prime&quot;))&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Chip&#8217;s approach is very inefficient and unreliable.</p>
<p>First, 2 is the only even prime number. No prime number can have an even even factor less than itself. Second, if a number is nonprime, it&#8217;ll have a factor &gt; 1 and  2^29. Very unwise to use Excel&#8217;s MOD in any formula involving factorization of arbitrary numbers.</p>
<p>So longer but more efficient to use</p>
<p>=IF(OR(A1INT(A1),A12,A1/2=INT(A1/2))),&#8221;not prime&#8221;,<br />
IF(OR(A1/(2*ROW($A$1:INDEX($A:$A,INT(SQRT(A1)/2)))+1)<br />
=INT(A1/(2*ROW($A$1:INDEX($A:$A,INT(SQRT(A1)/2)))+1))),<br />
&#8220;not prime&#8221;,&#8221;prime&#8221;))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chip Pearson</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/06/30/is-this-number-prime/#comment-34794</link>
		<dc:creator>Chip Pearson</dc:creator>
		<pubDate>Mon, 15 Sep 2008 12:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1182#comment-34794</guid>
		<description>&lt;p&gt;If you are interested in a worksheet formula to determine if a number is prime (no VBA required), you can use the following array formula. It will test numbers between 2 and 65536 (Excel 2003 and earlier) or between 2 and 1,000,000 (Excel 2007). It tests whether the number in A1 is a prime, a prime twin, or not prime.&lt;/p&gt;
&lt;p&gt;=IF(AND((MOD($A$1,ROW(INDIRECT(&quot;2:&quot;&amp;$A$1-1)))0)),IF(OR(AND((MOD($A$1-2,ROW(INDIRECT(&quot;2:&quot;&amp;$A$1-3)))0)),AND((MOD($A$1+2,ROW(INDIRECT(&quot;2:&quot;&amp;$A$1+1)))0))),&quot;prime twin&quot;,&quot;prime&quot;),&quot;not prime&quot;)&lt;/p&gt;
&lt;p&gt;Since this a an array formula, you MUST press CTRL SHIFT ENTER rathen than just Enter when you enter the formula and whenever you edit later. I have no idea if there is really a practical use for this, but it is kind of cool.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>If you are interested in a worksheet formula to determine if a number is prime (no VBA required), you can use the following array formula. It will test numbers between 2 and 65536 (Excel 2003 and earlier) or between 2 and 1,000,000 (Excel 2007). It tests whether the number in A1 is a prime, a prime twin, or not prime.</p>
<p>=IF(AND((MOD($A$1,ROW(INDIRECT(&#8220;2:&#8221;&amp;$A$1-1)))0)),IF(OR(AND((MOD($A$1-2,ROW(INDIRECT(&#8220;2:&#8221;&amp;$A$1-3)))0)),AND((MOD($A$1+2,ROW(INDIRECT(&#8220;2:&#8221;&amp;$A$1+1)))0))),&#8221;prime twin&#8221;,&#8221;prime&#8221;),&#8221;not prime&#8221;)</p>
<p>Since this a an array formula, you MUST press CTRL SHIFT ENTER rathen than just Enter when you enter the formula and whenever you edit later. I have no idea if there is really a practical use for this, but it is kind of cool.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: logic</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/06/30/is-this-number-prime/#comment-20775</link>
		<dc:creator>logic</dc:creator>
		<pubDate>Sun, 27 Aug 2006 20:27:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1182#comment-20775</guid>
		<description>&lt;p&gt;the fastest way to find consecutive primes is to create an array and cross out all the non prim numbes.&lt;/p&gt;
&lt;p&gt;any way here is a very basic prime checker&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://logic-dust.blogspot.com/2006/08/primary-number-checker.html&quot; rel=&quot;nofollow&quot;&gt;http://logic-dust.blogspot.com/2006/08/primary-number-checker.html&lt;/a&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>the fastest way to find consecutive primes is to create an array and cross out all the non prim numbes.</p>
<p>any way here is a very basic prime checker</p>
<p><a href="http://logic-dust.blogspot.com/2006/08/primary-number-checker.html" rel="nofollow">http://logic-dust.blogspot.com/2006/08/primary-number-checker.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean McCloskey</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/06/30/is-this-number-prime/#comment-20638</link>
		<dc:creator>Sean McCloskey</dc:creator>
		<pubDate>Thu, 17 Aug 2006 17:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1182#comment-20638</guid>
		<description>&lt;p&gt;It&#039;s faster just to divide by known primes up to Sqr(Num) as Eric Bachtal says.  No need to divide by all odd number or all numbers that are congruent to 1 mod 6 and 5 mod 6.  Faster still if you are trying to find all prime numbers in a certain range (so I&#039;ve heard -- I plan to test this out myself when I have a chance) is to set up a Sieve of Erastothenes, which eliminates numbers that aren&#039;t prime, rather than testing every number for primeness.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>It&#8217;s faster just to divide by known primes up to Sqr(Num) as Eric Bachtal says.  No need to divide by all odd number or all numbers that are congruent to 1 mod 6 and 5 mod 6.  Faster still if you are trying to find all prime numbers in a certain range (so I&#8217;ve heard &#8212; I plan to test this out myself when I have a chance) is to set up a Sieve of Erastothenes, which eliminates numbers that aren&#8217;t prime, rather than testing every number for primeness.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Devyn</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/06/30/is-this-number-prime/#comment-16508</link>
		<dc:creator>Devyn</dc:creator>
		<pubDate>Sat, 01 Oct 2005 18:07:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1182#comment-16508</guid>
		<description>&lt;p&gt;I dont understand why you wouldnt just put on a graph of prime #s&lt;br&gt;
u absoulutley need to do this! plz and thanx&lt;br&gt;
                Devyn Fortunati&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I dont understand why you wouldnt just put on a graph of prime #s<br />
u absoulutley need to do this! plz and thanx<br />
                Devyn Fortunati</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/06/30/is-this-number-prime/#comment-15536</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Wed, 13 Jul 2005 23:21:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1182#comment-15536</guid>
		<description>&lt;p&gt;This seems to work for primes &gt; 3.&lt;/p&gt;
&lt;p&gt;   If Num  Int(Num) Then Exit Function&lt;br&gt;
   Select Case Num Mod 6&lt;br&gt;
      Case 1, 5&lt;br&gt;
         Dim i As Long&lt;br&gt;
         For i = 5 To Sqr(Num) Step 6&lt;br&gt;
            If Num Mod i = 0 Then Exit Function&lt;br&gt;
            If Num Mod i + 2 = 0 Then Exit Function&lt;br&gt;
         Next i&lt;br&gt;
      Case Else&lt;br&gt;
         Exit Function&lt;br&gt;
   End Select&lt;br&gt;
   IsPrime = True&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>This seems to work for primes &gt; 3.</p>
<p>   If Num  Int(Num) Then Exit Function<br />
   Select Case Num Mod 6<br />
      Case 1, 5<br />
         Dim i As Long<br />
         For i = 5 To Sqr(Num) Step 6<br />
            If Num Mod i = 0 Then Exit Function<br />
            If Num Mod i + 2 = 0 Then Exit Function<br />
         Next i<br />
      Case Else<br />
         Exit Function<br />
   End Select<br />
   IsPrime = True</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Hoch</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/06/30/is-this-number-prime/#comment-14426</link>
		<dc:creator>Paul Hoch</dc:creator>
		<pubDate>Thu, 07 Jul 2005 03:21:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1182#comment-14426</guid>
		<description>&lt;p&gt;I wonder how large a number you can use without clogging up your cpu resources.  A long time ago, I used to run a program to check for mersenne prime numbers (2^prime number - 1) and it used to take weeks to determine the answer.  For more interesting info on Mersenne prime numbers you can check out this site - &lt;a href=&quot;http://www.utm.edu/research/primes/mersenne/&quot; rel=&quot;nofollow&quot;&gt;http://www.utm.edu/research/primes/mersenne/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In case you&#039;re wondering I sometimes still want to be a mathematician.  It fascinates me.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I wonder how large a number you can use without clogging up your cpu resources.  A long time ago, I used to run a program to check for mersenne prime numbers (2^prime number &#8211; 1) and it used to take weeks to determine the answer.  For more interesting info on Mersenne prime numbers you can check out this site &#8211; <a href="http://www.utm.edu/research/primes/mersenne/" rel="nofollow">http://www.utm.edu/research/primes/mersenne/</a></p>
<p>In case you&#8217;re wondering I sometimes still want to be a mathematician.  It fascinates me.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

