![]() |
Largest Prime Number
What is the largest prime number that can be represented numerically in Excel?
I realize there are an infinite quantity of prime numbers, but I am not concerned with primes that are so large that they can only be represented as Text. Thanks in advance. -- Gary''s Student - gsnu200815 |
Largest Prime Number
Gary: I did some experimenting and I think the answer is 99999999977. Excel
says the accuracy is 15 places which I assume is binary which would mean that the largest number is &HFFFF. I tried larger number and found the largest number is 99999999999 (eleven 9's). Twelve 9's gave me scientific notation which means the number was larger than the accuracy of excel. I then wrote a quick program to find the largest number less than 99999999999. See program below. Sub getprime() Num = 99999999999# Prime = 0 For N = Num To 1 Step -2 SqareRoot = Sqr(Num) Prime = True For N1 = 3 To SqareRoot step 2 Div = Int(N / N1) Mult = Div * N1 If N = Mult Then Prime = False Exit For End If Next N1 If Prime = True Then Prime = N Exit For End If Next N MsgBox ("Prime = " & Prime) End Sub "Gary''s Student" wrote: What is the largest prime number that can be represented numerically in Excel? I realize there are an infinite quantity of prime numbers, but I am not concerned with primes that are so large that they can only be represented as Text. Thanks in advance. -- Gary''s Student - gsnu200815 |
Largest Prime Number
Hi,
On the assumption you mean up to a max of 15 digits then the largest 10 a- 999999999999989 999999999999947 999999999999883 999999999999877 999999999999827 999999999999809 999999999999659 999999999999643 999999999999577 999999999999571 Mike Mike "Gary''s Student" wrote: What is the largest prime number that can be represented numerically in Excel? I realize there are an infinite quantity of prime numbers, but I am not concerned with primes that are so large that they can only be represented as Text. Thanks in advance. -- Gary''s Student - gsnu200815 |
Largest Prime Number
No, the 15 places are decimal.
-- David Biddulph "Joel" wrote in message ... Gary: I did some experimenting and I think the answer is 99999999977. Excel says the accuracy is 15 places which I assume is binary which would mean that the largest number is &HFFFF. I tried larger number and found the largest number is 99999999999 (eleven 9's). Twelve 9's gave me scientific notation which means the number was larger than the accuracy of excel. I then wrote a quick program to find the largest number less than 99999999999. See program below. Sub getprime() Num = 99999999999# Prime = 0 For N = Num To 1 Step -2 SqareRoot = Sqr(Num) Prime = True For N1 = 3 To SqareRoot step 2 Div = Int(N / N1) Mult = Div * N1 If N = Mult Then Prime = False Exit For End If Next N1 If Prime = True Then Prime = N Exit For End If Next N MsgBox ("Prime = " & Prime) End Sub "Gary''s Student" wrote: What is the largest prime number that can be represented numerically in Excel? I realize there are an infinite quantity of prime numbers, but I am not concerned with primes that are so large that they can only be represented as Text. Thanks in advance. -- Gary''s Student - gsnu200815 |
Largest Prime Number
Thanks!
-- Gary''s Student - gsnu200815 "Mike H" wrote: Hi, On the assumption you mean up to a max of 15 digits then the largest 10 a- 999999999999989 999999999999947 999999999999883 999999999999877 999999999999827 999999999999809 999999999999659 999999999999643 999999999999577 999999999999571 Mike Mike "Gary''s Student" wrote: What is the largest prime number that can be represented numerically in Excel? I realize there are an infinite quantity of prime numbers, but I am not concerned with primes that are so large that they can only be represented as Text. Thanks in advance. -- Gary''s Student - gsnu200815 |
Largest Prime Number
Thanks!
-- Gary''s Student - gsnu200815 "Joel" wrote: Gary: I did some experimenting and I think the answer is 99999999977. Excel says the accuracy is 15 places which I assume is binary which would mean that the largest number is &HFFFF. I tried larger number and found the largest number is 99999999999 (eleven 9's). Twelve 9's gave me scientific notation which means the number was larger than the accuracy of excel. I then wrote a quick program to find the largest number less than 99999999999. See program below. Sub getprime() Num = 99999999999# Prime = 0 For N = Num To 1 Step -2 SqareRoot = Sqr(Num) Prime = True For N1 = 3 To SqareRoot step 2 Div = Int(N / N1) Mult = Div * N1 If N = Mult Then Prime = False Exit For End If Next N1 If Prime = True Then Prime = N Exit For End If Next N MsgBox ("Prime = " & Prime) End Sub "Gary''s Student" wrote: What is the largest prime number that can be represented numerically in Excel? I realize there are an infinite quantity of prime numbers, but I am not concerned with primes that are so large that they can only be represented as Text. Thanks in advance. -- Gary''s Student - gsnu200815 |
Largest Prime Number
Gary''s Student wrote:
What is the largest prime number that can be represented numerically in Excel? I realize there are an infinite quantity of prime numbers, but I am not concerned with primes that are so large that they can only be represented as Text. Thanks in advance. Hi. Just to be different.... Numerically, and with no "Text", vba can represent a larger number. Sub Demo() Dim n '// Not a Prime of course n = CDec(491848789357#) * 13 * 9241 * 464773 * 2884993 '// Adding 10 is a Prime, and the largest Prime in Excel vba n = n + 10 Debug.Print FormatNumber(n, 0, , , vbTrue) 'ie 79,228,162,514,264,337,593,543,950,319 '// Adding 16 is ok. n = n + 16 '// Adding one more puts us at overfolw n = n + 1 End Sub - - - :) Dana DeLouis |
Largest Prime Number
Thanks!
-- Gary''s Student - gsnu200815 "Dana DeLouis" wrote: Gary''s Student wrote: What is the largest prime number that can be represented numerically in Excel? I realize there are an infinite quantity of prime numbers, but I am not concerned with primes that are so large that they can only be represented as Text. Thanks in advance. Hi. Just to be different.... Numerically, and with no "Text", vba can represent a larger number. Sub Demo() Dim n '// Not a Prime of course n = CDec(491848789357#) * 13 * 9241 * 464773 * 2884993 '// Adding 10 is a Prime, and the largest Prime in Excel vba n = n + 10 Debug.Print FormatNumber(n, 0, , , vbTrue) 'ie 79,228,162,514,264,337,593,543,950,319 '// Adding 16 is ok. n = n + 16 '// Adding one more puts us at overfolw n = n + 1 End Sub - - - :) Dana DeLouis |
Largest Prime Number
Hi,
Because Excel switches to scientific notation does not mean the it can't handle larger numbers or that its accuracy is only out to 11 places. In the spreadsheet the accuracy could be out to 15 places just as the Help system states. I say could because whether a result is accurate to 15 decimals depends on what your calculating and you its handled in binary. Cheers, Shane Devenshire "Joel" wrote: Gary: I did some experimenting and I think the answer is 99999999977. Excel says the accuracy is 15 places which I assume is binary which would mean that the largest number is &HFFFF. I tried larger number and found the largest number is 99999999999 (eleven 9's). Twelve 9's gave me scientific notation which means the number was larger than the accuracy of excel. I then wrote a quick program to find the largest number less than 99999999999. See program below. Sub getprime() Num = 99999999999# Prime = 0 For N = Num To 1 Step -2 SqareRoot = Sqr(Num) Prime = True For N1 = 3 To SqareRoot step 2 Div = Int(N / N1) Mult = Div * N1 If N = Mult Then Prime = False Exit For End If Next N1 If Prime = True Then Prime = N Exit For End If Next N MsgBox ("Prime = " & Prime) End Sub "Gary''s Student" wrote: What is the largest prime number that can be represented numerically in Excel? I realize there are an infinite quantity of prime numbers, but I am not concerned with primes that are so large that they can only be represented as Text. Thanks in advance. -- Gary''s Student - gsnu200815 |
Largest Prime Number
Purely for anyone interested I used a cell formatted as number with no
decimal places and Morefunc to get these numbers. The function =PN.ISPRIME(n) can adequately handle numbers of this size. http://xcell05.free.fr/morefunc/english/ Mike "Gary''s Student" wrote: Thanks! -- Gary''s Student - gsnu200815 "Mike H" wrote: Hi, On the assumption you mean up to a max of 15 digits then the largest 10 a- 999999999999989 999999999999947 999999999999883 999999999999877 999999999999827 999999999999809 999999999999659 999999999999643 999999999999577 999999999999571 Mike Mike "Gary''s Student" wrote: What is the largest prime number that can be represented numerically in Excel? I realize there are an infinite quantity of prime numbers, but I am not concerned with primes that are so large that they can only be represented as Text. Thanks in advance. -- Gary''s Student - gsnu200815 |
Largest Prime Number
The largest prime number that can be represented in IEEE double precision is
=2^53-111 This value is 9007199254740881, which has 16 decimal digits, so Excel will not correctly display the final digit, since it displays no more than 15 decimal digits, but the formula will give you the correct value, as can be verified by appropriate subtraction. Jerry "Gary''s Student" wrote: What is the largest prime number that can be represented numerically in Excel? I realize there are an infinite quantity of prime numbers, but I am not concerned with primes that are so large that they can only be represented as Text. Thanks in advance. -- Gary''s Student - gsnu200815 |
All times are GMT +1. The time now is 05:53 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com