Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,670
Default How to determine the number of common factors?

Does anyone have any suggestions on how to determine the number of common
factors based on given number? For example,
10 is given in cell A1, then the common factors for 10 are 1,2,5,10. There
are 4 numbers for common factors, then I will return 4 in cell B1.
I will try different number in cell A1,
Does anyone have any suggestions on how to determine the number of common
factors in cell B2?
Thanks in advance for any suggestions
Eric
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default How to determine the number of common factors?

Use the function below. Call with

=NumberFactors(10)

Function NumberFactors(target)

'include target
'then you only need to check 1/2 the numbers
NumberFactors = 1
For i = 1 To target / 2
If target Mod i = 0 Then
NumberFactors = NumberFactors + 1
End If
Next i

End Function


"Eric" wrote:

Does anyone have any suggestions on how to determine the number of common
factors based on given number? For example,
10 is given in cell A1, then the common factors for 10 are 1,2,5,10. There
are 4 numbers for common factors, then I will return 4 in cell B1.
I will try different number in cell A1,
Does anyone have any suggestions on how to determine the number of common
factors in cell B2?
Thanks in advance for any suggestions
Eric

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default How to determine the number of common factors?

Try this:

=SUMPRODUCT(--(MOD(A1,ROW(INDIRECT("1:"&A1)))=0))

Works only with integers. If the number is 0 you'll get an error. If it's
possible that the number can be 0 then use this version:

=IF(AND(ISNUMBER(A1),A1=0),1,SUMPRODUCT(--(MOD(A1,ROW(INDIRECT("1:"&A1)))=0)))

--
Biff
Microsoft Excel MVP


"Eric" wrote in message
...
Does anyone have any suggestions on how to determine the number of common
factors based on given number? For example,
10 is given in cell A1, then the common factors for 10 are 1,2,5,10. There
are 4 numbers for common factors, then I will return 4 in cell B1.
I will try different number in cell A1,
Does anyone have any suggestions on how to determine the number of common
factors in cell B2?
Thanks in advance for any suggestions
Eric



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default How to determine the number of common factors?

Improvement:

This takes care of 0 in a different way and accounts for an empty cell:

=IF(A1="","",SUMPRODUCT(--(MOD(A1,ROW(INDIRECT("1:"&MAX(1,A1))))=0)))

--
Biff
Microsoft Excel MVP


"T. Valko" wrote in message
...
Try this:

=SUMPRODUCT(--(MOD(A1,ROW(INDIRECT("1:"&A1)))=0))

Works only with integers. If the number is 0 you'll get an error. If it's
possible that the number can be 0 then use this version:

=IF(AND(ISNUMBER(A1),A1=0),1,SUMPRODUCT(--(MOD(A1,ROW(INDIRECT("1:"&A1)))=0)))

--
Biff
Microsoft Excel MVP


"Eric" wrote in message
...
Does anyone have any suggestions on how to determine the number of common
factors based on given number? For example,
10 is given in cell A1, then the common factors for 10 are 1,2,5,10.
There
are 4 numbers for common factors, then I will return 4 in cell B1.
I will try different number in cell A1,
Does anyone have any suggestions on how to determine the number of common
factors in cell B2?
Thanks in advance for any suggestions
Eric





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
need help finding most common number and so on tht Excel Discussion (Misc queries) 2 May 28th 07 02:59 PM
Any function to determine the smallest common factor from a list? Eric Excel Discussion (Misc queries) 4 December 10th 06 07:47 PM
most common number Jeff New Users to Excel 1 February 16th 06 09:02 AM
how do I find prime factors of a number Jeff Excel Worksheet Functions 16 November 30th 05 11:41 AM
what is the max number of factors in Linest function apca Excel Worksheet Functions 1 October 14th 05 12:55 PM


All times are GMT +1. The time now is 09:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"