Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I am looking for an add-in that would allow you to find the highest
prime divisor in a number. ie 68, 2x2x17, so 17 is the highest prime. Any help would be much appreciated... |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Here is a function that I adapted from something I found in a Google
Function MaxPrime(limit As Long) Dim PrimeCnt As Long Dim y As Long Dim x As Long Dim Primes ReDim Primes(1 To limit) PrimeCnt = 1 If limit Mod 2 = 0 Then Primes(PrimeCnt) = 2 PrimeCnt = PrimeCnt + 1 End If If limit Mod 3 = 0 Then Primes(PrimeCnt) = 3 PrimeCnt = PrimeCnt + 1 End If x = 3 Do x = x + 2 For y = 3 To Sqr(x) Step 2 If x Mod y = 0 Then GoTo noprime Next y If limit Mod x = 0 Then Primes(PrimeCnt) = x PrimeCnt = PrimeCnt + 1 End If noprime: Loop Until x limit MaxPrime = Application.Max(Primes) End Function -- HTH Bob Phillips (remove nothere from email address if mailing direct) wrote in message ups.com... I am looking for an add-in that would allow you to find the highest prime divisor in a number. ie 68, 2x2x17, so 17 is the highest prime. Any help would be much appreciated... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Determining the highest number in a row | Excel Discussion (Misc queries) | |||
to find number of days between 2 dates using vba code in excel | Excel Discussion (Misc queries) | |||
Lookup Highest Number | Excel Discussion (Misc queries) | |||
How to find highest, lowest and last cell in row? | Excel Discussion (Misc queries) | |||
How do I find the first value in a column less than a number? | Excel Worksheet Functions |